我的网站React工作正常,但我正在尝试修复这个控制台错误。每次点击产生这个:
Uncaught TypeError: Cannot read properties of undefined (reading '0')
at Array.<anonymous> (content.js:7:89199)
at c.trigger (content.js:7:81786)
at HTMLDocument.<anonymous> (content.js:7:81253)
无论在网站的哪个位置。
我试着删除组件,看看它是否来自某个特定的东西,但我最终删除了整个app.js的内容,它仍然发生。
知道要找什么吗?
我使用React + Vite+ typescript +Tailwind
我的主. tsx
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import { AxiosInterceptor } from "./interceptors/axios.interceptor";
AxiosInterceptor();
const root = ReactDOM.createRoot(document.getElementById("root")!)!;
root.render(<App />);
我的应用程序. tsx
import { BrowserRouter as Router, Route, Navigate } from "react-router-dom";
import Landing from "./pages/landing/Landing";
import Sidebar from "./components/Sidebar/Sidebar";
import Footer from "./components/Footer/Footer";
import { PrivateRoutes, PublicRoutes } from "./models";
import { AuthGuard } from "./guards";
import { RoutesWithNotFound } from "./utilities";
import { lazy, Suspense } from "react";
import { Provider } from "react-redux";
import store from "./redux/store";
import { LinkedInCallback } from "react-linkedin-login-oauth2";
const Login = lazy(() => import("./pages/login/Login"));
const Signup = lazy(() => import("./pages/signup/Signup"));
const Private = lazy(() => import("./pages/private/Private"));
function App() {
return (
<Suspense
fallback={
<div className="flex items-center h-screen justify-center">
<div className="w-16 h-16 border-4 border-dashed rounded-full animate-spin border-red-600"></div>
</div>
}
>
<Provider store={store}>
<Router>
<Sidebar />
<RoutesWithNotFound>
<Route path="/" element={<Navigate to={PrivateRoutes.PRIVATE} />} />
<Route path={PublicRoutes.LANDING} element={<Landing />} />
<Route path={PublicRoutes.LOGIN} element={<Login />} />
<Route
path={PublicRoutes.LINKEDIN_LOGIN}
element={<LinkedInCallback />}
/>
<Route
path={PublicRoutes.LINKEDIN_REGISTER}
element={<LinkedInCallback />}
/>
<Route path={PublicRoutes.SIGNUP} element={<Signup />} />
<Route element={<AuthGuard />}>
<Route
path={`${PrivateRoutes.PRIVATE}/*`}
element={<Private />}
/>
</Route>
</RoutesWithNotFound>
<Footer />
</Router>
</Provider>
</Suspense>
);
}
export default App;
错误指向的文件是这个(最后一行显然是错误的原因)
1条答案
按热度按时间j5fpnvbx1#
该错误与content.js有关。
这是一个可以与浏览器访问的网页交互的脚本(例如,请参见https://developer.chrome.com/docs/extensions/mv3/content_scripts)
该错误仅发生在Chrome中。我使用的是Chrome 109.0.5414.119。原因是在一个扩展中。将名为“访问站点”的Chrome扩展“Typio Form Recovery”中的设置更改为特定站点,而不是所有站点或“单击”解决了该问题。
错误原因不是应用程序代码,而是Chrome扩展。
(Same每次点击时,Angular应用程序都会出错。上面列表中唯一常见的依赖项是TypeScript。我使用的是TypeScript 4.9.4。)