-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
56 lines (55 loc) · 1.36 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-default/index.css">
</head>
<body>
<div id="app">
<el-button @click="exportCsv">export table data to csv file </el-button>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
prop="col1"
label="foo">
</el-table-column>
<el-table-column
prop="col2"
label="bar">
</el-table-column>
<el-table-column
prop="col3"
label="baz">
</el-table-column>
</el-table>
</div>
</body>
<!-- 先引入 Vue -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<!-- 依赖于csv.js-->
<script src="./dist/csv.min.js"></script>
<script src="./dist/csv-exportor.min.js"></script>
<script>
new Vue({
el: '#app',
data: function() {
return {
tableData: [{col1:'a',col2:'b',col3:'c'},{col1:'d',col2:'e',col3:'f'}],
header: ["foo","bar","baz"],
}
},
methods: {
exportCsv: function() {
csvExportor.downloadCsv(
this.tableData,
{ header: this.header },
'test.csv');
}
}
})
</script>
</html>