hansontable基础之属性使用(vue)
导入组件(先要NPM安装)
import { HotTable } from "@handsontable/vue";
import Handsontable from "handsontable";
注册组件
components: { HotTable }
使用hot-table组件
<HotTable :root="text" ref="textHot" :settings="hotSettings" :language="language"></HotTable>
设置hansontable属性
export default {
data() {
return {
hotSettings: {
data: 设置数据,
width: 100, // 定义表格宽高
height: 50,
}
}
}
}
属性名称(在settings中设置)作用
data设置每一行的数据(用数组表示【【第一行】,【第二行】,【第三行】】)width设置表格宽高heightcolWidths:设置行高列宽(可以是数组)rowHeightsclassName设置文字位置(htCenter,htLeft,htRight,htJustify,htTop,htMiddle,htBottom)colHeaders: true列列标题是否显示rowHeaders: truestartRows: 19起始表格大小startCols: 6minRows最小行列minColsmaxRows: 50最大行列maxCols: 50minSpareCols: 1行列空白大小minSpareRows: 5autoWrapRow自动换行columnSorting排序fixedColumnsLeft: 0固定行列数(标题除外)fixedRowsTop: 6,mergeCells:合并单元格,语法:{ “row”: 0, “col”: 0, “rowspan”: 1, “colspan”: 13 },cell单元格属性,语法:{ “row”: 0, “col”: 0, “className”: “htLift htMiddle” },contextMenu右键菜单(值有很多)manualColumnResize:true拖拽行头或列头改变行或列的大小manualRowResize:autoColumnSize:当值为true且列宽未设置时,自适应列大小dropdownMenu: true下拉菜单filters:true下拉菜单过滤器readOnly: true只读licenseKey非商用:“non-commercial-and-evaluation”
最后再给大家附上两篇有关hansontable的博客,讲的挺详细 有关handsontable的一些简单操作 Handsontable–在线Excel表格