简体   繁体   English

Vue3 元素不显示

[英]Vue3 element not displaying

I'm new to vue and i'm starting a project where i want to use a library https://github.com/tochoromero/vuejs-smart-table .我是 vue 的新手,我正在开始一个我想使用库https://github.com/tochoromero/vuejs-smart-table的项目。

At the moment i have a simple app:目前我有一个简单的应用程序:

<template>
    <img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />

    <v-table :data="users">
      <thead slot="head">
          <th>Name</th>
          <th>Age</th>
      </thead>
      <tbody slot="body" slot-scope="{displayData}">
          <tr v-for="row in displayData" :key="row.id">
            <td>{{ row.id }}</td>
            <td>{{ row.title }}</td>
          </tr>
      </tbody>
    </v-table>
  </template>

<script>
import users from './data/karaoke.json'

export default {
    name: 'users',
    data: () => ({
        users
    })
}
</script>

That should read the rows from my karaoke.json and display them as a table right?那应该从我的 karaoke.json 中读取行并将它们显示为表格吗? At least following the documentation here https://tochoromero.github.io/vuejs-smart-table/the-basics/#table .至少遵循此处的文档https://tochoromero.github.io/vuejs-smart-table/the-basics/#table

What happens is that nothing is displayed on the page, is just the vue logo and the DOM for the vtable is empty.发生的情况是页面上没有显示任何内容,只有 vue 徽标和 vtable 的 DOM 是空的。 On the other side if i use vue chrome dev tools and inspect the page i can see that the vtable actually does have data in it, is just not being displayed.另一方面,如果我使用 vue chrome 开发工具并检查页面,我可以看到 vtable 实际上确实有数据,只是没有显示。

Is there something I'm doing wrong here?我在这里做错了什么吗? The code is live in this repo https://github.com/jiwidi/lens_database代码在这个 repo https://github.com/jiwidi/lens_database

Looks like your markup is for the Vue 2 version of Smart Table.看起来您的标记是针对 Vue 2 版本的 Smart Table 的。 Check out the docs for the new Vue 3 compatible version (which is the package you're using).查看新的 Vue 3 兼容版本的文档(这是您正在使用的 package)。 You need to use a <template> tag now to pass in slot props.您现在需要使用<template>标签来传递插槽道具。

<v-table :data="users">
 <template #head>
   <thead slot="head">
     <th>Title</th>
     <th>Artist</th>
   </thead>
 </template>
 <template #body="{ rows }">
   <tbody>
     <tr v-for="row in rows" :key="row.id">
       <td>{{ row.id }}</td>
       <td>{{ row.title }}</td>
     </tr>
   </tbody>
 </template>
</v-table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM