actionList.includes is not a function?

store.js方法:

actions: {

async getBtnPermission({ commit }) {

const res = await getBtnCode();

const arr = res.split(',');

console.log('按钮权限列表', arr);

commit('updateBtnPerm', arr);

},

},

main.js内使用:

// 按钮权限指令

Vue.directive('has', {

inserted: (el, binding) => {

let actionList = store.dispatch('getBtnPermission');

console.log('actionList', actionList);

let values = binding.value;

let hasPermission = actionList.includes(values);

if (!hasPermission) {

el.style = 'display:none';

setTimeout(() => {

el.parentNode.removeChild(el);

}, 0);

}

},

});

为什么会报actionList.includes is not a function


回答:

await 呢? async 的返回值是个 promise

我看你也打印了 actionList

昂。actions 的返回是什么呢?commit 是指触发 mutation


所以你应该 await 一下,然后从 store 中读取一下 actionList

以上是 actionList.includes is not a function? 的全部内容, 来源链接: utcz.com/p/933339.html

回到顶部