no message
Former-commit-id: e0e48f558e24126a96d5088c66f2fa51b05a1812 Former-commit-id: c2b3c1ea34a8442086cd4303e724ef6331950514 Former-commit-id: c45a1c1ab9787521f01a5d411a91adb2f61ffe61
This commit is contained in:
@@ -32,7 +32,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import papa from 'papaparse'
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -47,16 +46,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleUpload (file) {
|
handleUpload (file) {
|
||||||
papa.parse(file, {
|
this.$import.csv(file)
|
||||||
header: true,
|
.then(res => {
|
||||||
skipEmptyLines: true,
|
this.table.columns = Object.keys(res.data[0]).map(e => ({
|
||||||
complete: (results, file) => {
|
|
||||||
this.table.columns = Object.keys(results.data[0]).map(e => ({
|
|
||||||
label: e,
|
label: e,
|
||||||
prop: e
|
prop: e
|
||||||
}))
|
}))
|
||||||
this.table.data = results.data
|
this.table.data = res.data
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,19 @@
|
|||||||
// 库
|
// 库
|
||||||
|
import papa from 'papaparse'
|
||||||
export default {
|
export default {
|
||||||
install (Vue, options) {
|
install (Vue, options) {
|
||||||
Vue.prototype.$import = {
|
Vue.prototype.$import = {
|
||||||
//
|
csv (file) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
papa.parse(file, {
|
||||||
|
header: true,
|
||||||
|
skipEmptyLines: true,
|
||||||
|
complete: (results, file) => {
|
||||||
|
resolve(results)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user