Youngbye
Youngbye

Reputation: 65

Using mapActions error without Object.assign?

x.vue file

methods: {
    ...mapActions([
      'fetchTopicVideo',
    ]),
}

It will be throw error, and the error info is :

ERROR in ./~/buble-loader!./~/vue-loader/lib/selector.js?

type=script&index=0!./src/components/CardList.vue
Module build failed:
43 :     // }, (res) => {
44 :     //   console.log('query error')
45 :     // })
46 :   },
47 :   methods: {
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Object spread operator requires specified objectAssign option with 'Object.assign' or polyfill helper. (47:11)
 @ ./src/components/CardList.vue 7:2-105
 @ ./~/buble-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./src/views/ClientTopicShare.vue
 @ ./src/views/ClientTopicShare.vue
 @ ./src/router/index.js
 @ ./src/app.js
 @ ./src/client-entry.js
 @ multi webpack-hot-middleware/client ./src/client-entry.js

But the code below will not throw error:

methods: Object.assign({},
   mapActions([
     'fetchTopicVideo'
   ])
)

.babelrc file:

{
  "presets": ["es2015", "stage-2"],
  "plugins": ["transform-runtime"],
  "comments": false
}

Maybe the babel fail cause this.

Upvotes: 2

Views: 868

Answers (1)

Youngbye
Youngbye

Reputation: 65

The problem is solved by https://github.com/vuejs/vue-hackernews-2.0/issues/87

Install the buble, edit vue-loader.config.js

module.exports = {
    ...
    buble: {
        objectAssign: 'Object.assign',
    },
}

Upvotes: 3

Related Questions