vueday02——使用NTableData

1.下载naivueui

2.按需导入,不要全局导入

注意不要导入错误组件或者写错组件名称

import { NDataTable } from 'naive-ui'

3.定义表头和数据!!!

n-data-table标签必须要使用数据和数据 少一个都不能正确渲染!!!

const data = ref([
    {
        key: 0,
        name: 'John Brown',
        age: 32,
        address: 'New York No. 1 Lake Park',
        tags: ['nice', 'developer']
    },
    {
        key: 1,
        name: 'Jim Green',
        age: 42,
        address: 'London No. 1 Lake Park',
        tags: ['wow']
    },
    {
        key: 2,
        name: 'Joe Black',
        age: 32,
        address: 'Sidney No. 1 Lake Park',
        tags: ['cool', 'teacher']
    }
])

const column =ref([
    {
      title: 'Name',
      key: 'name'
    },
    {
      title: 'Age',
      key: 'age'
    },
    {
      title: 'Address',
      key: 'address'
    },
    {
      title: 'Tags',
      key: 'tags',
    }],
)

4.全部代码

<!--
 * @Author: LiuQidong 254818216@qq.com
 * @Date: 2023-10-17 02:38:53
 * @LastEditors: LiuQidong 254818216@qq.com
 * @LastEditTime: 2023-10-17 09:26:20
 * @FilePath: \newvue2\src\components\helloLQD.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <n-data-table
    :data="data"
    :columns="column"
    :bordered="true"
  />
  <p>111</p>
</template>

<script setup="ts">
import { ref, defineComponent } from 'vue'
import { NDataTable } from 'naive-ui'

const data = ref([
    {
        key: 0,
        name: 'John Brown',
        age: 32,
        address: 'New York No. 1 Lake Park',
        tags: ['nice', 'developer']
    },
    {
        key: 1,
        name: 'Jim Green',
        age: 42,
        address: 'London No. 1 Lake Park',
        tags: ['wow']
    },
    {
        key: 2,
        name: 'Joe Black',
        age: 32,
        address: 'Sidney No. 1 Lake Park',
        tags: ['cool', 'teacher']
    }
])

const column =ref([
    {
      title: 'Name',
      key: 'name'
    },
    {
      title: 'Age',
      key: 'age'
    },
    {
      title: 'Address',
      key: 'address'
    },
    {
      title: 'Tags',
      key: 'tags',
    }],
)
</script>

5.实际效果

相关推荐
北极无雪12 分钟前
Spring源码学习(拓展篇):SpringMVC中的异常处理
java·开发语言·数据库·学习·spring·servlet
猿小猴子23 分钟前
Python3 爬虫 中间人爬虫
开发语言·爬虫·python
lly20240631 分钟前
Swift 方法
开发语言
YONG823_API43 分钟前
电商平台数据批量获取自动抓取的实现方法分享(API)
java·大数据·开发语言·数据库·爬虫·网络爬虫
寂柒1 小时前
C++——模拟实现stack和queue
开发语言·c++·算法·list
蜜桃小阿雯1 小时前
JAVA开源项目 旅游管理系统 计算机毕业设计
java·开发语言·jvm·spring cloud·开源·intellij-idea·旅游
Benaso1 小时前
Rust 快速入门(一)
开发语言·后端·rust
wjs20242 小时前
HTML5 新元素
开发语言
慕明翰2 小时前
Springboot集成JSP报 404
java·开发语言·spring boot
satan–02 小时前
R语言的基本语句及基本规则
开发语言·windows·r语言