随笔分类 - react
摘要:第一步:执行以下命令: npm run eject 第二步:在package.json 中修改代码 "eslintConfig": { "extends": [ "react-app", "react-app/jest" ], "rules":{ "no-undef":"off" } }, 第三步:
阅读全文
摘要:v5中的嵌套路由: 主页面v5中使用{this.props.children}来接收子页面 import React, { Component } from 'react'; export default class About extends Component { render() { retu
阅读全文
摘要:使用react中的router v6版本踩坑记录。 根据报错的意思提示大概就是要给路由提供一个上下文 一开始我的index.js是这样的: import React from 'react'; import ReactDOM from 'react-dom/client'; import './in
阅读全文
摘要:使用Route报错:A <Route> is only ever to be used as the child of <Routes> element, never rendered directl 报错原因是react-router-dom依赖为6版本,需要使用6版本的写法 function r
阅读全文
摘要:原因是使用class定义组件的时候 component写成小写的,如下: class Page extends React.component 正确的应该是:(Component要大写) class Page extends React.Component
阅读全文