no message

Former-commit-id: ed8b79ee506e129b017755712ebef9591c386b2e
Former-commit-id: c806994f8ea03cf18c2b67435bdac3a73748cba9
Former-commit-id: 251168680ac04b8385babfc997aeb3e991f9ec57
This commit is contained in:
李杨
2018-02-14 17:04:03 +08:00
parent a056301b0b
commit c178ee2182
2 changed files with 44 additions and 44 deletions

View File

@@ -0,0 +1,66 @@
<template>
<Container>
<PageHeader
slot="header"
title="基本示例"
url="https://github.com/mholt/PapaParse">
</PageHeader>
<el-row :gutter="10">
<el-col :span="4">
<div class="dd-mb">
<el-button @click="download">下载演示CSV</el-button>
</div>
<el-upload :before-upload="handleUpload" action="default">
<el-button type="success">选择 CSV 文件</el-button>
</el-upload>
</el-col>
<el-col :span="20">
<el-table v-bind="table" style="width: 100%">
<el-table-column
v-for="(item, index) in table.columns"
:key="index"
:prop="item.prop"
:label="item.label">
</el-table-column>
</el-table>
</el-col>
</el-row>
</Container>
</template>
<script>
import papa from 'papaparse'
export default {
data () {
return {
table: {
columns: [],
data: [],
size: 'mini',
stripe: true,
border: true
}
}
},
methods: {
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
},
download () {
window.location.href = 'http://fairyever.qiniudn.com/d2admin-vue-demo.csv'
}
}
}
</script>