'decodeUriComponent' 未定义 no-undef

'decodeUriComponent' is not defined no-undef

出于某种原因,我收到一条错误消息 'decodeUriComponent'。下面的代码可以查看它。首先我以为我必须导入 decodeUriComponent 但我找不到任何与我需要导入它相关的信息。我走了大约 30 分钟,但找不到导致此问题的任何原因。如果有人告诉我我需要做什么或我需要在我的代码中修复什么以便用 React

解决这个问题,我会非常感激

谢谢

    // https://develoepr.spotify.com/
// documentation/web-playback-sdk/quick-start/#
export const authEndpoint = "https://accounts.spotify.com/authorize";
const redirectUri = "http://localhost:3000/";
const clientId = "xxxxxxxxxxxxxxxxxxx";

const scopes = [
    "user-read-currently-playing",
    "user-read-recently-played",
    "user-read-playback-state",
    "user-top-read",
    "user-modify-playback-state",
];

export const getTokenFromUrl = () => {
    return window.location.hash
    .substring(1)
    .split("&")
    .reduce((initial, item) => {
        let parts = item.split("=");
        initial[parts[0]] = decodeUriComponent(parts[1]);

        return initial;
    }, {});
}

export const loginUrl = `${authEndpoint}?client_id=${clientId}&redirect_uri=${redirectUri}&scope=${scopes.join("%20")}&response_type=token&show_dialog=true`;

它是 decodeURIComponent(大写的 URI)而不是 decodeUriComponent