https://github.com/advancedcat/taro-react-router
The demo for using react-router in Taro.
https://github.com/advancedcat/taro-react-router
miniprogram react-router taro
Last synced: 26 days ago
JSON representation
The demo for using react-router in Taro.
- Host: GitHub
- URL: https://github.com/advancedcat/taro-react-router
- Owner: AdvancedCat
- Created: 2022-08-18T09:41:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-10T02:30:11.000Z (about 2 years ago)
- Last Synced: 2025-03-25T23:11:15.289Z (about 1 month ago)
- Topics: miniprogram, react-router, taro
- Language: JavaScript
- Homepage:
- Size: 1.79 MB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# taro-react-router
本 DEMO 用于检验 Taro 项目使用 `react-router` 开发多路由页面。
## 如何开发
### For webpack5
#### Taro 仓库
1. 克隆 Taro 仓库: `git clone https://github.com/NervJS/taro.git` ;
2. 安装依赖 `pnpm i`;
3. 切换至 `feat/3.6` 分支;
4. 编译包 `pnpm build`;
5. 将 `@tarojs/runtime` `@tarojs/webpack5-runner` 链接到全局
```bash
$ cd packages/taro-runtime
$ pnpm link --global
$ cd packages/taro-webpack5-runner
$ pnpm link --global
```#### 本仓库
1. 克隆本仓库:`git clone https://github.com/AdvancedCat/taro-react-router.git`;
2. 安装依赖:`pnpm i`;
3. 链接包 `@tarojs/runtime` `@tarojs/webpack5-runner`;
```bash
$ pnpm link --global @tarojs/runtime
$ pnpm link --global @tarojs/webpack5-runner
```4. 运行 `npm run dev:weapp`,在微信开发者工具中即可预览效果;
观察终端输出的 `Prebundle dependencies:` 列表这种是否包含 `react-router-dom` 提示。
### For Webpack4
安装 `webpack@^4`,同时修改 `config/index.js` 配置文件中 `compiler: "webpack4"`
Taro 仓库将包 `@tarojs/runtime` `@tarojs/mini-runner` 链接到全局:
```bash
$ cd packages/taro-runtime
$ pnpm link --global
$ cd packages/taro-mini-runner
$ pnpm link --global
```链接包 `@tarojs/runtime` `@tarojs/mini-runner`:
```bash
$ pnpm link --global @tarojs/runtime
$ pnpm link --global @tarojs/mini-runner
```