tiny-vue/examples/sites/demos/pc/app/grid/dynamically-columns/reverse-columns-composition...

56 lines
1.3 KiB
Vue

<template>
<div>
<div>
<tiny-button @click="change"> 反转列顺序 </tiny-button>
</div>
<br />
<tiny-grid :data="tableData">
<tiny-grid-column v-for="col in cols" :key="col.field" v-bind="col"></tiny-grid-column>
</tiny-grid>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { TinyGrid, TinyGridColumn, TinyButton } from '@opentiny/vue'
const cols = ref([
{
field: 'introduction',
title: '公司简介'
},
{
field: 'address',
title: '地址'
}
])
const tableData = ref([
{
id: '1',
name: 'GFD 科技有限公司',
area: '华东区',
address: '福州',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。'
},
{
id: '2',
name: 'WWWW 科技有限公司',
area: '华南区',
address: '深圳福田区',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。'
},
{
id: '3',
name: 'RFV 有限责任公司',
area: '华南区',
address: '中山市',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。'
}
])
function change() {
cols.value.reverse()
}
</script>