1.0.3 • Published 1 year ago
mytable-ui v1.0.3
安装:
npm i mytable-ui
使用:
// 在vue3 项目的 main.js 文件中安装组件
import MyTableUI from 'mytable-ui'
const app = createApp(App)
app.use(MyTableUI)
示例:
<script setup>
import { reactive, ref } from 'vue'
const tableData = reactive([
{ id: 1, name: '张三', age: 20 },
{ id: 2, name: '亚瑟', age: 20 },
{ id: 2, name: '孙猴', age: 22 },
{ id: 3, name: '兰陵王', age: 21 },
{ id: 4, name: '孙尚香', age: 18 },
])
const btnClick = (data) => {
console.log('操作,被点击了', data.name)
}
const btnClick22 = (data) => {
console.log('操作,被点击了22', data.age)
}
</script>
<template>
<div>
<p>HELLO My-table</p>
<my-table :tableData="tableData">
<my-col prop="id" label="ID"></my-col>
<my-col prop="name" label="姓名"></my-col>
<my-col prop="age" label="年龄"></my-col>
<my-col label="操作">
<template v-slot="scope">
<button @click="btnClick(scope)">操作姓名</button>
<button @click="btnClick22(scope)">操作年龄</button>
</template>
</my-col>
</my-table>
</div>
</template>
<style lang="scss" scoped></style>