小编Yan*_*ick的帖子

Redux Toolkit 与 WebStorm 不能很好地配合

我正在学习 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.reducer
Run Code Online (Sandbox Code Playgroud)

正如您在上面看到的,第一个图像是 WebStorm,第二个图像是 vscode。

Vscode 检测到所有方法,WebStorm 没有,我在 google 上没有发现任何类似的问题。

我想知道在 WebStorm 上看不到这些方法是否很正常,这会很奇怪,WebStorm 通常很强大。

javascript autocomplete webstorm reactjs redux

7
推荐指数
1
解决办法
1652
查看次数

标签 统计

autocomplete ×1

javascript ×1

reactjs ×1

redux ×1

webstorm ×1