簡體   English   中英

package react-router 中的 index.tsx 有 152 個問題

[英]index.tsx in package react-router has 152 problems

一切似乎都很好,我只看到那些錯誤。 這是正常的嗎? 我怎樣才能解決這個問題。 我的反應應用程序是在 Javascript 中編寫的,而不是在 Typescript 中,但我認為這不重要,不是嗎?

在此處輸入圖像描述

您是否使用像 npm/yarn/pnpm 這樣的 package 管理器來安裝 react-router? 看着那個路徑名,它看起來你不是,你應該是。

If you're trying to import the index.tsx file directly in your JavaScript it won't work, you'll need the transpiled version which would be available automatically by installing it through a package manager (something like npm install react-router ). 然后,可以在項目根目錄的node_modules/react-router下使用純 js 文件。

要將其導入 React 項目中的某個位置,您可以使用:

import { Route } from 'react-router'

(不需要完整的路徑名,包括 node_modules - 有關 npm 的更多信息安裝在這里: https://docs.npmjs.com/cli/v6/commands/npm-install

我只是重新啟動了 Visual Studio 代碼,錯誤就消失了。

對於上下文,我已經運行了幾天的 Visual Studio,所以我可以看到這會導致一些錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM