[英]index.tsx in package react-router has 152 problems
您是否使用像 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.