vue(六) vue集合handsontable实现在线excel表格编辑

编程入门 行业动态 更新时间:2024-10-10 12:21:01

vue(六)  vue集合handsontable实现<a href=https://www.elefans.com/category/jswz/34/1770935.html style=在线excel表格编辑"/>

vue(六) vue集合handsontable实现在线excel表格编辑

handsontable官网地址:.1.0/tutorial-custom-build.html

1.安装

npm install handsontable @handsontable/vue

 

2.引入css,

方式1 
在app.vue中引入 
<style src="../node_modules/handsontable/dist/handsontable.full.css"></style> 
方式2 
在main.js中引入 
import 'handsontable/dist/handsontable.full.css';
方式3
在vue组件中引入 
<style> @import '~handsontable/dist/handsontable.full.css'; </style>

 

3.添加License key,去掉提示文字

<hot-table :settings="settings" licenseKey="non-commercial-and-evaluation" />
<script>import {HotTable} from '@handsontable/vue';import Handsontable from 'handsontable';export default {name: 'HelloWorld',data() {return {hotSettings: {data: Handsontable.helper.createSpreadsheetData(6, 10),colHeaders: true,colHeaders: true,}}},components: {HotTable}}
</script>

4.传递数据方式

方式1:
<hot-table :settings="hotSettings" />
setting:子组件接收数据属性方式2:
<hot-table:settings="hotSettings"licenseKey="non-commercial-and-evaluation":data="tableData"style="height:300px;overflow:auto;"></hot-table><script>data() {return {hotSettings: {tableClassName: ['table01', 'htCenter'],stretchH: 'all',preventOverflow: 'vertical', //防止水平溢出表 },data:''//你的对象数组或者二维数组,可以使用计算属性给其赋值等}},
</script>

5.设置行.列表头显示

//默认行列头部 
colHeaders: true,rowHeaders: true,//自定义行列头部 
colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'],//对象数组头部设置
dataSchema: {//预定义对象属性car: null,year: null,chassisColor: null,bumperColor: null},colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'],//也可以为汉字columns: [//对象属性与预定义属性对应{ data: 'car', readOnly: true },{ data: 'year'

更多推荐

vue(六) vue集合handsontable实现在线excel表格编辑

本文发布于:2024-02-06 17:12:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1750530.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在线   表格   编辑   vue   handsontable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!