我正在遷移到vuejs 2,並且我的vue組件有一個非常奇怪的問題。當我需要()的組分,我接收在所述的WebPack捆綁過程如下錯誤:使用webpack捆綁vuejs 2組件的問題
ERROR in Unexpected token >
該錯誤的行號是其中要求()調用來加載組件。
這是我收到錯誤的測試組件的例子:
<template>
<div>
<button>test</button>
</div>
</template>
<script>
module.exports = {
data: function() {
return {
}
}
}
</script>
我webpack.config.js文件是:
const webpack = require('webpack');
require('es6-promise').polyfill();
var path = require("path");
module.exports = {
entry: {
...
},
output: {
//path: path.join(__dirname, "./dist/js"),
path: './',
filename: "[name].bundle.js",
chunkFilename: "[id].chunk.js"
},
devServer: {
...
},
module: {
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel-loader',
// make sure to exclude 3rd party code in node_modules
exclude: /node_modules/
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file?name=public/fonts/[name].[ext]'
}
]
},
vue: {
loaders: {
js: 'babel-loader'
}
},
resolveLoader: {
root: __dirname + '/node_modules'
},
resolve: {
alias: {
'vue': 'vue/dist/vue'
}
}
};
任何幫助將是非常讚賞。我已經在這個幾個小時內陷入了困境。
該組件是.vue的擴展嗎? – riscarrott