当前位置:网站首页>Routing interception of WeChat applet
Routing interception of WeChat applet
2022-07-31 17:54:00 【Program ape to run forward】
直接上代码
我们知道vueCan intercept routes,The WeChat applet requires us to verify the routing interceptor ourselves
// utils/filter.js
function loginCheck(pageObj) {
if (pageObj.onLoad) {
let _onLoad = pageObj.onLoad;
// 使用onLoad的话需要传递options
pageObj.onLoad = function (options) {
if(wx.getStorageSync('USERID')) {
// 获取当前页面
let currentInstance = getPageInstance();
_onLoad.call(currentInstance, options);
} else {
//跳转到登录页
wx.redirectTo({
url: "/pages/login/login"
});
}
}
}
return pageObj;
}
// 获取当前页面
function getPageInstance() {
var pages = getCurrentPages();
return pages[pages.length - 1];
}
exports.loginCheck = loginCheck;
边栏推荐
- 【愚公系列】2022年07月 Go教学课程 021-Go容器之切片操作
- ECCV 2022 华科&ETH提出首个用于伪装实例分割的一阶段Transformer的框架OSFormer!代码已开源!...
- Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
- Flutter gets the height of the status bar statusbar
- 最新神作!阿里巴巴刚出炉的面试参考指南(泰山版),我直接狂刷29天
- MySQL common statements
- 常用的安全渗透测试工具(渗透测试工具)
- Flutter set the background color of the statusbar status bar and APP method (AppBar) internal consistent color.
- 多主复制下处理写冲突(3)-收敛至一致的状态及自定义冲突解决逻辑
- 2022 Android interview summary (with interview questions | source code | interview materials)
猜你喜欢
Kotlin coroutines: continuation, continuation interceptor, scheduler
IP protocol from 0 to 1
leetcode:6135. 图中的最长环【内向基环树 + 最长环板子 + 时间戳】
ThreadLocal
Huawei mobile phone one-click to open "maintenance mode" to hide all data and make mobile phone privacy more secure
最新神作!阿里巴巴刚出炉的面试参考指南(泰山版),我直接狂刷29天
All-platform GPU general AI video supplementary frame super-score tutorial
Golang——从入门到放弃
【pytorch】pytorch 自动求导、 Tensor 与 Autograd
程序员如何学习开源项目,这篇文章告诉你
随机推荐
UVM RAL模型和内置seq
[Source code analysis] BeanFactory and FactoryBean
你辛辛苦苦写的文章可能不是你的原创
多线程之锁
最后写入胜利(丢弃并发写入)
【Yugong Series】July 2022 Go Teaching Course 022-Dictionary of Go Containers
保证接口数据安全的10种方式
组合学笔记(六)局部有限偏序集的关联代数,Möbius反演公式
After Effects 教程,如何在 After Effects 中调整过度曝光的快照?
新型电信“套路”,我爸中招了!
[TypeScript]OOP
JS基础小练习
认识异常 (看完这篇你就懂了)
Write a database document management tool based on WPF repeating the wheel (1)
iNeuOS工业互联网操作系统,设备运维业务和“低代码”表单开发工具
MySQL---排序与分页
go mode tidy出现报错go warning “all“ matched no packages
Combinatorics Notes (6) Associative Algebra of Locally Finite Partially Ordered Sets, Möbius Inversion Formula
华为顶级工程师历时9年总结的“趣谈网络协议”PDF文档,太强了
Jiuqi ny3p series voice chip replaces the domestic solution KT148A, which is more cost-effective and has a length of 420 seconds