-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
路由中间件功能 #11378
Labels
enhancement
New feature or request
Comments
等待热心的小伙伴解决问题中..., 有一些相关的 issues 可能帮助到你! Thank you so much! |
This was referenced Mar 11, 2022
Closed
加个 HOC 吧,好像没有更好的办法 |
给个参考方案: /**
* 防止用户越过正常流程,例如说直接通过连接访问,或者尝试越权访问
* taro 目前不支持路由中间件,需开发者在需要鉴权的页面包装多一层
* <Auth>
* <Order/>
* </Auth>
*/
import { View } from "@tarojs/components";
import React, { useEffect, useState } from 'react';
import { appAuth } from "@/utils";
export default props => {
const [hasAuth, setHasAuth] = useState(false);
const { children, ...params } = props;
useEffect(() => {
appAuth(params).then(({ success }) => setHasAuth(success));
}, []);
return <View>{hasAuth ? children : 'noAuth '}</View>;
}; 使用 function Order() { return <View><View>}
export default function AuthOrder() {
return <Auth projectName='order'>
<Order />;
</Auth>
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这个特性解决了什么问题?
有一个全局登录信息的获取接口,要在进入页面前获取完成并存入storage,并在页面中使用,原来可以写在路由守卫之类的中间件中,请问现在应该写在哪里呢?
这个 API 长什么样?
类似路由中间件之类的功能
The text was updated successfully, but these errors were encountered: