IT이야기

Object.assign 없이 mapActions 오류 사용?

cyworld 2022. 5. 5. 10:16
반응형

Object.assign 없이 mapActions 오류 사용?

x.vue 파일

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

에러가 발생하며 에러 정보는 다음과 같다.

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

그러나 아래 코드는 오류를 발생시키지 않을 것이다:

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

.babelrc 파일:

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

개코원숭이가 실패해서 이러는 걸지도 몰라

이 문제는 https://github.com/vuejs/vue-hackernews-2.0/issues/87에 의해 해결되었다.

버블 설치, vue-loader.config.js 편집

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

참조URL: https://stackoverflow.com/questions/42552636/using-mapactions-error-without-object-assign

반응형