参考iOS开发中的 UINavigationController 的思想,实现了在React项目中的类似 iOS 页面转场的效果。
github:navigation-controller
- 使用方式
1
| $ npm install @lilong767676/navigation-controller
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import { NavigationController } from '@lilong767676/navigation-controller';
export const routes = { root: App, [RouteNames.addFriendPage]: AddFriendsPage, [RouteNames.newFriendsPage]: NewFriendsPage, [RouteNames.chatHome]: ChatHome, [RouteNames.chatPage]: ChatPage, };
const naviController = new NavigationController(routes);
naviController.setRootContainer(ele);
NavigationController.push(RouteNames.addFriendPage, props);
NavigationController.pop();
naviController.destroy();
|
效果: