随笔分类 -  react

摘要:第一步:执行以下命令: npm run eject 第二步:在package.json 中修改代码 "eslintConfig": { "extends": [ "react-app", "react-app/jest" ], "rules":{ "no-undef":"off" } }, 第三步: 阅读全文
posted @ 2022-09-13 15:50 秃头的铲屎官 阅读(1871) 评论(0) 推荐(0) 编辑
摘要:v5中的嵌套路由: 主页面v5中使用{this.props.children}来接收子页面 import React, { Component } from 'react'; export default class About extends Component { render() { retu 阅读全文
posted @ 2022-09-09 17:52 秃头的铲屎官 阅读(347) 评论(0) 推荐(0) 编辑
摘要:使用react中的router v6版本踩坑记录。 根据报错的意思提示大概就是要给路由提供一个上下文 一开始我的index.js是这样的: import React from 'react'; import ReactDOM from 'react-dom/client'; import './in 阅读全文
posted @ 2022-09-09 17:09 秃头的铲屎官 阅读(1547) 评论(0) 推荐(0) 编辑
摘要:使用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 阅读全文
posted @ 2022-09-09 17:02 秃头的铲屎官 阅读(475) 评论(0) 推荐(0) 编辑
摘要:原因是使用class定义组件的时候 component写成小写的,如下: class Page extends React.component 正确的应该是:(Component要大写) class Page extends React.Component 阅读全文
posted @ 2022-09-01 16:43 秃头的铲屎官 阅读(824) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示