Files
mes-ui-d2/static/markdownFiles/article/插件 - 导入.md
李杨 7d33bcd766 no message
Former-commit-id: 6227cdd80eec53ed1b810ab3fc7646f115e938f8
Former-commit-id: 71352eacb31449a67d1cb85b14b0fdb9e167ca63
Former-commit-id: a78fd4fd48a759286325b88822f96b794396db57
2018-02-15 15:44:27 +08:00

27 lines
558 B
Markdown

解析 CSV 文件使用 [PapaParse](https://github.com/mholt/PapaParse)
```
// 导入插件
import papa from 'papaparse'
//在选择文件后处理数据
handleUpload (file) {
papa.parse(file, {
header: true,
skipEmptyLines: true,
complete: (results, file) => {
// 设置表格列
this.table.columns = Object.keys(results.data[0]).map(e => ({
label: e,
prop: e
}))
// 表格赋值
this.table.data = results.data
}
})
return false
}
```
> 详细的papaparse使用API请移步官网文档