我的webpack編譯器沒有被轉譯成正確的JS。它寫道vue.js with vue-multilanguage我的webpack編譯器沒有被正確翻譯
exports default MultiLanguage
而不是 module.exports = { MultiLanguage: MultiLanguage};
我.bablerc
{
"presets": ["es2015", "stage-0"],
"plugins": ["transform-runtime"]
}
我的package.json
{
"name": "myapp",
"version": "0.0.1",
"description": "My app",
"dependencies": {
"bootstrap": "^3.3.7",
"vue": "^2.4.2",
"vue-multilanguage": "^2.1.1"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-loader": "^6.4.1",
"babel-plugin-transform-runtime": "^6.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.1.2",
"babel-runtime": "^5.8.0",
"webpack": "^1.15.0"
},
"author": "You"
}
我webpack.config.js
module.exports = {
entry: './src/main.js',
output: {
path: './dist',
filename: 'build.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}
]
}
}
及其所用的錯誤,並在那裏打在build.js代碼 在Chromium/Chrome的UND Ubuntu的:
Uncaught SyntaxError: Unexpected token export
:
SyntaxError: export declarations may only appear at top level of a module
export default MultiLanguage
這裏也vue code(main.js):
import Vue from 'vue/dist/vue.js'
import MultiLanguage from 'vue-multilanguage/src/vue-multilanguage.js'
Vue.use(MultiLanguage, {
default: 'en',
en: {
hi: 'Hello',
welcome: 'Welcome, {name}'
},
pt: {
hi: 'Ola',
welcome: 'Bem-vindo, {name}'
}
})
任何推薦的教程?任何想法?
當我更換build.js行機智module.exports = { MultiLanguage: MultiLanguage};
誤差不occure
我從來沒有使用過之前使用的元素屬性語法。這可能會導致你的錯誤。你檢查過控制檯嗎?我可以打賭,由於v.lang.welcome屬性,vue在渲染模板時遇到問題。我不認爲這是正確的HTML5。 –
我必須承認。我從模塊的教程 – helle
複製它我建議尋找另一個教程,因爲你使用的語法看起來不像我見過的任何東西。 –