clear
Former-commit-id: e2bfcb0f40765724b17e13056e8293ec271efefb [formerly e2bfcb0f40765724b17e13056e8293ec271efefb [formerly e2bfcb0f40765724b17e13056e8293ec271efefb [formerly e2bfcb0f40765724b17e13056e8293ec271efefb [formerly 5793d72d458b7eeaf28a097d026168cebc9fc256 [formerly 9c8de3644bd40a55711e618742e29cce390e4c5f]]]]] Former-commit-id: 05ca3c8da65f8583c142720628aa6ea71d2dbf45 Former-commit-id: 7a4d2fba696e901db86071ea2810e9c932c976ad Former-commit-id: c18d3689200ca0e528fbf9bf171f6e1b50131bc3 [formerly 455e9952ca890cd8ad882250cfb9eabd944d44ee] Former-commit-id: 021fa8191681fe4f22e9a9f40389831a847e9066 Former-commit-id: 1022b7792417ce366901b9d5284762a015dd6d26 Former-commit-id: bed799410be508713cac76b7c8cf02d4457fe996 Former-commit-id: f6787cfaac3404132ad1011e2707e08484708ca9 Former-commit-id: 7a8a3baca9ef30393744fd56def6d608b51dcddd
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
# 表格导入
|
||||
|
||||
本框架集成了数据导入功能,并包装成插件
|
||||
|
||||
## 注册插件
|
||||
|
||||
``` js
|
||||
import pluginImport from '@/plugin/import'
|
||||
Vue.use(pluginImport)
|
||||
```
|
||||
|
||||
之后就可以在组件中使用 `this.$import` 来调用导出功能
|
||||
|
||||
::: tip
|
||||
d2admin 已经帮你注册好,可以直接使用,无需写上面的代码
|
||||
:::
|
||||
|
||||
## 导入 csv
|
||||
|
||||
导入csv文件,并且返回一个 `Promise` 对象
|
||||
|
||||
``` js
|
||||
// 在选择文件后调用
|
||||
handleUpload (file) {
|
||||
this.$import.csv(file)
|
||||
.then(res => {
|
||||
this.table.columns = Object.keys(res.data[0]).map(e => ({
|
||||
label: e,
|
||||
prop: e
|
||||
}))
|
||||
this.table.data = res.data
|
||||
})
|
||||
// 阻止默认的上传
|
||||
return false
|
||||
}
|
||||
```
|
||||
|
||||
## 导入 xlsx
|
||||
|
||||
导入xlsx文件,并且返回一个 `Promise` 对象
|
||||
|
||||
**注意 导入的表格文件第一行应为表头**
|
||||
|
||||
参考下述示例使用
|
||||
|
||||
``` js
|
||||
// 在选择文件后调用
|
||||
handleUpload (file) {
|
||||
this.$import.xlsx(file)
|
||||
.then(({header, results}) => {
|
||||
// header 为表头
|
||||
// results 为内容
|
||||
this.table.columns = header.map(e => {
|
||||
return {
|
||||
label: e,
|
||||
prop: e
|
||||
}
|
||||
})
|
||||
this.table.data = results
|
||||
})
|
||||
// 阻止默认的上传
|
||||
return false
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user