gpt4 book ai didi

javascript - vue+webpack,系统告诉我 "Module build failed: TypeError: this._init is not a function"

转载 作者:行者123 更新时间:2023-12-01 17:38:40 26 4
gpt4 key购买 nike

我不知道如何修复它,我搜索了太多信息,所有人都告诉我我没有安装 npm 模块,但我的 'package.json' 文件已经安装了它们。

我已经安装了所有的 npm 模块

dependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-runtime": "^6.22.0",
"css-loader": "^0.26.1",
"style-loader": "^0.13.1",
"vue": "^2.1.10",
"vue-hot-reload-api": "^2.0.8",
"vue-html-loader": "^1.2.3",
"vue-loader": "^10.3.0",
"vue-template-compiler": "^2.1.10",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0"}

其他文件
webpack.config.js

module.exports={
entry:'./main.js',

output:{
path:__dirname,
filename:'build.js'
},

module:{
loaders:[
{test:/\.vue$/, loader:'vue'},
{test:/\.js$/, loader:'babel-loader', exclude:/node_modules/}
]
}};

主要.js

import Vue from 'vue'
import App from './App.vue'

new Vue({
el:'body',
components:{
app:App
}
});

App.vue

<template>
<h1>welcome Vue</h1>
</template>

<script type="text/javascript"></script>

<style type="text/css"></style>

和最终文件

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="bundle.js"></script>
</head>
<body>
<div id="app">
<app></app>
</div>
</body>
</html>

当我启动 webpack-dev-server 时,shell 告诉我 TypeError: this._init is not a function

(ps:我的英文不好,所以....)

我已经解决了这个问题,在'webpack.config.js'文件中

{test:/\.vue$/, loader:'vue'}

改为

{test:/.vue$/, loader:'vue-loader'}

因为我用的是vue 2.0版本。

最佳答案

webpack.config.js中的一行应该是全名:

{test:/\.vue$/, loader:'vue-loader'},

关于javascript - vue+webpack,系统告诉我 "Module build failed: TypeError: this._init is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42156190/

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