perf: use import replace require.ensure

This commit is contained in:
Pan
2017-12-21 13:25:29 +08:00
parent 0dfa56c73e
commit 7fef8568c2
4 changed files with 20 additions and 21 deletions

View File

@@ -60,13 +60,12 @@ export default {
},
handleDownload() {
this.downloadLoading = true
require.ensure([], () => {
const { export_json_to_excel } = require('@/vendor/Export2Excel')
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
const list = this.list
const data = this.formatJson(filterVal, list)
export_json_to_excel(tHeader, data, this.filename)
excel.export_json_to_excel(tHeader, data, this.filename)
this.downloadLoading = false
})
},

View File

@@ -66,16 +66,15 @@ export default {
handleDownload() {
if (this.multipleSelection.length) {
this.downloadLoading = true
require.ensure([], () => {
const { export_json_to_excel } = require('@/vendor/Export2Excel')
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
const list = this.multipleSelection
const data = this.formatJson(filterVal, list)
export_json_to_excel(tHeader, data, this.filename)
this.$refs.multipleTable.clearSelection()
this.downloadLoading = false
})
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
const list = this.multipleSelection
const data = this.formatJson(filterVal, list)
excel.export_json_to_excel(tHeader, data, this.filename)
this.$refs.multipleTable.clearSelection()
this.downloadLoading = false
})
} else {
this.$message({
message: '请至少选择一条记录',