Closed mengxin-FE closed 2 months ago
这段改成这样:
// start row index
const startRowIndex = ref(0)
// render row index
function renderRowIndex({ row, column, rowIndex }) {
// return <span>{rowIndex + startRowIndex.value + 1}</span>; // 需将本文件名后缀改为jsx
// h函数 https://cn.vuejs.org/api/render-function.html#h
return h('span', { class: '' }, rowIndex + startRowIndex.value + 1)
}
function scrolling({ startRowIndex: _startRowIndex, visibleStartIndex, visibleEndIndex, visibleAboveCount, visibleBelowCount }) {
startRowIndex.value = _startRowIndex;
}
columns 也要改成 computed:
const columns = computed(() => [
{
field: "index",
key: "index",
// is operation column
operationColumn: true,
title: "",
width: 55,
fixed: "left",
renderBodyCell: renderRowIndex,
},
...COLUMN_KEYS.map((keyValue) => {
return {
title: keyValue,
field: keyValue,
key: keyValue,
width: 90,
edit: true,
};
})
])
在组件中引入以下hooks可复现
组件代码:
hooks代码: import { ref } from 'vue' import { h } from 'vue'
export function useEasyTable() {
}