首页 > 解决方案 > 当我使用 vuex 时,laravel 返回 Unexpected token 错误

问题描述

我正在使用 laravel 和 vuejs。当我尝试从商店的方法访问时,vuex mapAction 出现意外的令牌错误。

这是我的 vue 组件中的代码:错误来自 mapActions 前面的三个点 (...)。

import { mapActions } from 'vuex';
export default {
    name:'SettingComponent',
    methods(){
       ...mapActions(['fetchSetting'])
    },
    created(){
       this.fetchSetting();
    }
}

标签: laravelvue.js

解决方案


try formatting it this way

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

推荐阅读