# 普通用法
点击查看代码
<template>
<div>
<ygp-crud ref="crud" :data="data" :option="option"></ygp-crud>
<div style="margin-top: 20px">
<el-button size="small" @click="toggleSelection([data[1]])">选中第二行</el-button>
<el-button size="small" @click="toggleSelection()">取消选择</el-button>
</div>
</div>
</template>
export default {
data() {
return {
data: [
{
name: "张三",
sex: "男",
date: "1994-02-23 00:00:00",
},
{
name: "李四",
sex: "女",
date: "1994-02-23 00:00:00",
},
{
name: "王五",
sex: "女",
date: "1994-02-23 00:00:00",
},
{
name: "赵六",
sex: "男",
date: "1994-02-23 00:00:00",
},
],
option: {
selection: true,
columns: [
{
label: "姓名",
prop: "name",
},
{
label: "性别",
prop: "sex",
},
{
label: "日期",
prop: "date",
},
],
},
};
},
methods: {
toggleSelection(val){
this.$refs.crud.toggleSelection(val);
}
}
};