Skip to content

Commit

Permalink
chore(table): split demo (#2761)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Dec 18, 2023
1 parent 98d7a22 commit 987d30c
Show file tree
Hide file tree
Showing 25 changed files with 986 additions and 2,095 deletions.
40 changes: 40 additions & 0 deletions packages/nutui-taro-demo/src/exhibition/pages/table/align.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<nut-table :columns="columns" :data="data"></nut-table>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const columns = ref([
{
title: '姓名',
key: 'name',
align: 'left'
},
{
title: '性别',
key: 'sex',
align: 'center'
},
{
title: '学历',
key: 'record',
align: 'right'
}
]);
const data = ref([
{
name: 'Tom',
sex: '',
record: '小学'
},
{
name: 'Lucy',
sex: '',
record: '本科'
},
{
name: 'Jack',
sex: '',
record: '高中'
}
]);
</script>
59 changes: 59 additions & 0 deletions packages/nutui-taro-demo/src/exhibition/pages/table/async.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<nut-table :columns="columns" :data="data">
<template #nodata>Loading...</template>
</nut-table>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
const columns = ref([
{
title: '姓名',
key: 'name'
},
{
title: '性别',
key: 'sex'
},
{
title: '学历',
key: 'record'
},
{
title: '年龄',
key: 'age'
},
{
title: '地址',
key: 'address'
}
]);
const data = ref<Array<any>>([]);
onMounted(() => {
setTimeout(() => {
data.value = [
{
address: '北京',
name: 'Tom',
sex: '',
record: '小学',
age: 13
},
{
record: '本科',
name: 'Lucy',
sex: '',
age: 34,
address: '上海'
},
{
name: 'Jack',
sex: '',
record: '高中',
age: 4,
address: '杭州'
}
];
}, 5000);
});
</script>
37 changes: 37 additions & 0 deletions packages/nutui-taro-demo/src/exhibition/pages/table/basic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<nut-table :columns="columns" :data="data"></nut-table>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const columns = ref([
{
title: '姓名',
key: 'name'
},
{
title: '性别',
key: 'sex'
},
{
title: '学历',
key: 'record'
}
]);
const data = ref([
{
name: 'Tom',
sex: '',
record: '小学'
},
{
name: 'Lucy',
sex: '',
record: '本科'
},
{
name: 'Jack',
sex: '',
record: '高中'
}
]);
</script>
37 changes: 37 additions & 0 deletions packages/nutui-taro-demo/src/exhibition/pages/table/border.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<nut-table :columns="columns" :data="data" :bordered="false"></nut-table>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const columns = ref([
{
title: '姓名',
key: 'name'
},
{
title: '性别',
key: 'sex'
},
{
title: '学历',
key: 'record'
}
]);
const data = ref([
{
name: 'Tom',
sex: '',
record: '小学'
},
{
name: 'Lucy',
sex: '',
record: '本科'
},
{
name: 'Jack',
sex: '',
record: '高中'
}
]);
</script>
68 changes: 68 additions & 0 deletions packages/nutui-taro-demo/src/exhibition/pages/table/custom.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<nut-table :columns="columns" :data="data"></nut-table>
</template>
<script setup lang="ts">
import { ref, h } from 'vue';
import { Dongdong } from '@nutui/icons-vue-taro';
const columns = ref([
{
title: '姓名',
key: 'name'
},
{
title: '性别',
key: 'sex'
},
{
title: '学历',
key: 'record'
},
{
title: '操作',
key: 'render'
}
]);
const data = ref([
{
name: 'Tom',
sex: '',
record: '小学',
render: () => {
return h(
'button',
{
onClick: () => {
console.log('hello');
}
},
'Hello'
);
}
},
{
name: 'Lucy',
sex: '',
record: '本科',
render: () => {
return h(Dongdong, { width: '14px', height: '14px ' });
}
},
{
name: 'Jack',
sex: '',
record: '高中',
render: () => {
return h(
'button',
{
onClick: () => {
window.open('https://www.jd.com');
}
},
'打开京东'
);
}
}
]);
</script>
Loading

0 comments on commit 987d30c

Please sign in to comment.