大概是只仓鼠 2021-10-14 16:18 采纳率: 79.6%
浏览 38
已结题

vue关于表格制作,小白问题,这个怎么改


<template>
  <div>我是测试页
  {{face}}</div>
  <div>
    <table border="1" cellspacing="1" cellpadding="1">
      <tr><th v-for="item in itemstitle",k:key="item">{{item}}</th></tr>
      <tr v-for="item in itemsvalue",k:key="item">
        <td>{{item.hours}}</td>
         <td>{{item.pass}}</td>
          <td>{{item.rej}}</td>
        </tr>
    </table>
  </div>
</template>

<script>
  export default {
    name: "PAGE2",
    data(){
      return{
        face:"测试",
        itemstitle:["name1","name2","name3"],
        itemsvalue:[{
          hours:"1",
          pass:"1-2",
          rej:"1-3"
        },{
          hours:"2",
          pass:"2-2",
          rej:"2-3"
        },{
          hours:"3",
          pass:"1-2",
          rej:"1-3"
        },]
      }
    },
  }
</script>

<style scoped>

</style>


这是错误提示


Failed to compile.

./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-51644a23","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/components/PAGE2.vue
(Emitted value instead of an instance of Error) 
  Error compiling template:
  
  <div>我是测试页
  {{face}}</div>
  <div>
    <table border="1" cellspacing="1" cellpadding="1">
      <tr><th v-for="item in items-title">{{item}}</th></tr>
      <tr v-for="item in items-value">
        <td>{{item.hours}}</td>
         <td>{{item.pass}}</td>
          <td>{{item.rej}}</td>
        </tr>
    </table>
  </div>
  
  - Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

 @ ./src/components/PAGE2.vue 11:0-361
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js
  • 写回答

2条回答 默认 最新

  • 落落Plus 2021-10-14 16:20
    关注

    img


    不知道你要改的是什么 首先这外部得有一个div包起来 只能有一个节点 th不需要tr包起来

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月22日
  • 已采纳回答 10月14日
  • 修改了问题 10月14日
  • 修改了问题 10月14日
  • 展开全部

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题