Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在vite下用安装后,会出现[plugin:vite:vue] <template v-for> key should be placed on the <template> tag.错误。 #45

Open
dzyuan opened this issue Oct 7, 2021 · 1 comment

Comments

@dzyuan
Copy link

dzyuan commented Oct 7, 2021

错误提示如下:
[plugin:vite:vue] key should be placed on the tag.
D:/GitHub/map/node_modules/@jiaminghi/data-view/lib/components/decoration6/src/main.vue:8:11
6 | >
7 | <rect
8 | :key="i"
| ^
9 | :fill="mergedColor[Math.random() > 0.5 ? 0 : 1]"
10 | :x="point[0] - halfRectWidth"
at createCompilerError (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:19:19)
at D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:3851:45
at Array.some ()
at D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:3847:31
at Array. (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:3978:13)
at traverseNode (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:2222:19)
at traverseChildren (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:2164:9)
at traverseNode (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:2215:13)
at traverseChildren (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:2164:9)
at traverseNode (D:\GitHub\map\node_modules@vue\compiler-core\dist\compiler-core.cjs.js:2215:13
Click outside or fix the code to dismiss.
You can also disable this overlay with hmr: { overlay: false } in vite.config.js.

错误位置源码如下:

<template>
  <div class="dv-decoration-6" :ref="ref">
    <svg :width="`${svgWH[0]}px`" :height="`${svgWH[1]}px`" :style="`transform:scale(${svgScale[0]},${svgScale[1]});`">
      <template
        v-for="(point, i) in points"
      >
        <rect
          :key="i"
          :fill="mergedColor[Math.random() > 0.5 ? 0 : 1]"
          :x="point[0] - halfRectWidth"
          :y="point[1] - heights[i] / 2"
          :width="rectWidth"
          :height="heights[i]"
        >

@jimpeo
Copy link

jimpeo commented Nov 20, 2021

That's what happened to me.
Do you guys have a solution now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants