SyntaxError: Unexpected token ... (82:8) in Browserify
SyntaxError: Unexpected token ... (82:8) in Browserify
我正在尝试使用 Vuex 中的 mapActions,如 Vuex Actions
中所示
methods:{
...mapActions([
'increment' // map this.increment() to this.$store.dispatch('increment')
])
}
但是,它在 ...
处给了我 SyntaxError: Unexpected token
。我不确定问题是什么以及我需要在问题中包含哪些细节。
尝试将此添加到您的 package.json
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
},
"env": {
"es6": true,
"browser": true
}
}
}
并且在你的 laravel-elixir 实例的 gulp 文件中检查 elixir.config.js.browserify.transformers
中是否有一个名为 babelify 的转换器,如果它存在则推入它的 options.presets
a字符串 stage-2
。这是我在 gulp 文件中的方式:
var elixir = require('laravel-elixir')
if (elixir.config.js.browserify.transformers[0].name === 'babelify') {
elixir.config.js.browserify.transformers[0].options.presets.push('stage-2');
}
您可能会有所不同,但您明白了。所有这些使得 browserify 使用 stage-2 功能编译资产,例如通常不会考虑的对象传播运算符。
1:安装标签插件:
npm install --save-dev babel-plugin-transform-object-rest-spread
2:然后修复.babelrc文件如下:
{
"presets": [["latest", {"es2015": { "modules": false }}]],
"plugins": ["transform-object-rest-spread"]
}
我正在尝试使用 Vuex 中的 mapActions,如 Vuex Actions
中所示methods:{
...mapActions([
'increment' // map this.increment() to this.$store.dispatch('increment')
])
}
但是,它在 ...
处给了我 SyntaxError: Unexpected token
。我不确定问题是什么以及我需要在问题中包含哪些细节。
尝试将此添加到您的 package.json
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
},
"env": {
"es6": true,
"browser": true
}
}
}
并且在你的 laravel-elixir 实例的 gulp 文件中检查 elixir.config.js.browserify.transformers
中是否有一个名为 babelify 的转换器,如果它存在则推入它的 options.presets
a字符串 stage-2
。这是我在 gulp 文件中的方式:
var elixir = require('laravel-elixir')
if (elixir.config.js.browserify.transformers[0].name === 'babelify') {
elixir.config.js.browserify.transformers[0].options.presets.push('stage-2');
}
您可能会有所不同,但您明白了。所有这些使得 browserify 使用 stage-2 功能编译资产,例如通常不会考虑的对象传播运算符。
1:安装标签插件:
npm install --save-dev babel-plugin-transform-object-rest-spread
2:然后修复.babelrc文件如下:
{
"presets": [["latest", {"es2015": { "modules": false }}]],
"plugins": ["transform-object-rest-spread"]
}