当前位置:网站首页>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;
边栏推荐
- Golang——从入门到放弃
- 关于柱状图的经典画法总结
- AcWing 1282. 搜索关键词 题解((AC自动机)Trie+KMP)+bfs)
- Automated testing - web automation - first acquaintance with selenium
- Multi-datacenter operation and detection of concurrent writes
- GP 6 overall architecture study notes
- Jiuqi ny3p series voice chip replaces the domestic solution KT148A, which is more cost-effective and has a length of 420 seconds
- Kotlin协程:续体、续体拦截器、调度器
- 每日练习------随机产生一个1-100之间的整数,看能几次猜中。要求:猜的次数不能超过7次,每次猜完之后都要提示“大了”或者“小了”。
- mysql的备份表的几种方法
猜你喜欢
随机推荐
MySQL---运算符
Bika LIMS open source LIMS set - use of SENAITE (detection process)
Multi-datacenter operation and detection of concurrent writes
[pytorch] pytorch automatic derivation, Tensor and Autograd
无主复制系统(1)-节点故障时写DB
After Effects 教程,如何在 After Effects 中调整过度曝光的快照?
Golang 必知必会Go Mod命令
Automated testing - web automation - first acquaintance with selenium
[Source code analysis] BeanFactory and FactoryBean
IP protocol from 0 to 1
Intelligent bin (9) - vibration sensor (raspberries pie pico implementation)
Masterless Replication System (3)-Limitations of Quorum Consistency
Huawei mobile phone one-click to open "maintenance mode" to hide all data and make mobile phone privacy more secure
使用 Flutter 和 Firebase 制作!计数器应用程序
【luogu P8326】Fliper (Graph Theory) (Construction) (Eulerian Circuit)
Handling Write Conflicts under Multi-Master Replication (1)-Synchronous and Asynchronous Conflict Detection and Conflict Avoidance
MySQL common statements
How to install CV2 smoothly in Anaconda
你辛辛苦苦写的文章可能不是你的原创
全平台GPU通用AI视频补帧超分教程









