no message

Former-commit-id: e0e48f558e24126a96d5088c66f2fa51b05a1812
Former-commit-id: c2b3c1ea34a8442086cd4303e724ef6331950514
Former-commit-id: c45a1c1ab9787521f01a5d411a91adb2f61ffe61
This commit is contained in:
李杨
2018-02-15 15:32:10 +08:00
parent 3170e42acd
commit c9689adcde
2 changed files with 17 additions and 10 deletions

View File

@@ -32,7 +32,6 @@
</template>
<script>
import papa from 'papaparse'
export default {
data () {
return {
@@ -47,16 +46,13 @@ export default {
},
methods: {
handleUpload (file) {
papa.parse(file, {
header: true,
skipEmptyLines: true,
complete: (results, file) => {
this.table.columns = Object.keys(results.data[0]).map(e => ({
this.$import.csv(file)
.then(res => {
this.table.columns = Object.keys(res.data[0]).map(e => ({
label: e,
prop: e
}))
this.table.data = results.data
}
this.table.data = res.data
})
return false
},

View File

@@ -1,8 +1,19 @@
// 库
import papa from 'papaparse'
export default {
install (Vue, options) {
Vue.prototype.$import = {
//
csv (file) {
return new Promise((resolve, reject) => {
papa.parse(file, {
header: true,
skipEmptyLines: true,
complete: (results, file) => {
resolve(results)
}
})
})
}
}
}
}