gpt4 book ai didi

Webpack 挂载 Vue 组件失败

转载 作者:搜寻专家 更新时间:2023-10-30 22:19:08 28 4
gpt4 key购买 nike

在使用 Webpack 和 Vue 编译项目后,当我打开一个使用 Vue 组件的页面时,我得到:

[Vue warn]: Failed to mount component: template or render function not defined.

代替 Vue 渲染的组件

<-- function (a, b, c, d) { return createElement(vm, a, b, c, d, true); } -->

为什么会出现这个错误?

备注:I've created an MCVE for this problem.使用的确切 Webpack 配置是:

module.exports = {
entry: __dirname + '/display.js',
output: {
filename: 'bundle.js'
},
module: {
rules: [ { test: /\.vue$/, loader: 'vue-loader' } ]
}
}

最佳答案

这仅仅是由于 change of vue-loader .

Since version 13.0.0, vue-loader doesn’t normalize exports anymore. You have to do
const app = require('./app.vue').default

所以只需将 display.js 中的 Child: require('./child.vue') 更改为 Child: require('./child.vue') vue').default 然后它就可以工作了。

关于Webpack 挂载 Vue 组件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45654720/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com