这是用nuxt/express生成的项目,nuxt.config.js的配置如下
/*
** Global CSS
*/
css: ['~/assets/css/main.css', 'element-ui/lib/theme-default/index.css'],
/*
** Add axios globally
*/
build: {
vendor: ['axios', 'element-ui'],
/*
** Run ESLINT on save
*/
extend (config, ctx) {
if (ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
},
babel: {
'plugins': [['component', [
{
'libraryName': 'element-ui',
'styleLibraryName': 'theme-default'
},
'transform-async-to-generator',
'transform-runtime'
]]],
comments: true
},
plugins: [
{ src: '~/plugins/element-ui', ssr: true }
]
}
然后plugins下面的element-ui.js的文件是这样的
import Vue from 'vue'
if (process.BROWSER_BUILD) {
Vue.use(require('element-ui'))
}
vue的版本是2.5.3,element-ui的版本是2.0.4,运行cnpm run dev之后就报错,在bulid阶段就这样
(node:30024) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: arguments[i].apply is not a function
假如吧build中的babel和plugins备注掉就可以正常bulid,请大神指点,快难住一天了
你有没有想过把babel和plugins放到build外面。。。