这个 eslint 错误的原因是什么以及如何修复它?

时间:2021-04-06 13:14:07

标签: typescript vuex eslint typescript-eslint

对于下面显示的代码,我收到以下 lint 错误。 如何解决? 任何值上的不安全成员访问 .item.eslint@typescript-eslint/no-unsafe-member-access

enter image description here

2 个答案:

答案 0 :(得分:2)

这个错误意味着 store.state 是任意的。确保它具有正确的类型。

答案 1 :(得分:0)

感谢 Logan Devine 和 Jesper 的帮助。

状态类型为 StateInterface。

我通过如下转换状态类型解决了这个问题。希望这个修复是正确的。

const itemName = computed(() =>  (<StateInterface> store.state).item.itemName)