我正在学习 Redux 和 Redux Toolkit,但我不明白为什么当我尝试分派操作时自动完成功能不起作用(请参见下图)。
我导入了“action”,但 WebStorm 看不到任何方法。
在 VSCode 上它运行得很好。
这里的动作:
import {createSlice} from "@reduxjs/toolkit";
const initialCounterState = { counter: 0, showCounter: true };
const counterSlice = createSlice({
name: "counter",
initialState: initialCounterState,
reducers: {
increment(state) {
state.counter++;
},
decrement(state) {
state.counter--;
},
increase(state, action) {
state.counter += action.payload;
},
toggleCounter(state) {
state.showCounter = !state.showCounter;
},
},
});
export const counterActions = counterSlice.actions;
export default counterSlice.reducerRun Code Online (Sandbox Code Playgroud)
正如您在上面看到的,第一个图像是 WebStorm,第二个图像是 vscode。
Vscode 检测到所有方法,WebStorm 没有,我在 google 上没有发现任何类似的问题。
我想知道在 WebStorm 上看不到这些方法是否很正常,这会很奇怪,WebStorm 通常很强大。