当前位置:网站首页>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;
边栏推荐
- 20.支持向量机—数学原理知识
- 【Yugong Series】July 2022 Go Teaching Course 022-Dictionary of Go Containers
- Mariabackup implements incremental data backup for Mariadb 10.3
- IP protocol from 0 to 1
- INeuOS industrial Internet operating system, the equipment operational business and "low code" form development tools
- 21.支持向量机—核函数的介绍
- go记录之——slice
- GP 6 overall architecture study notes
- UserAgent 解析
- Kotlin协程:续体、续体拦截器、调度器
猜你喜欢

【pytorch】pytorch 自动求导、 Tensor 与 Autograd

架构师04-应用服务间加密设计和实践

Tkinter 入门之旅

MySQL---单行函数
![[Network Communication 3] Advantech Gateway Modbus Service Settings](/img/ec/e9e1d9a374183ecaa8a8c9437ec82c.png)
[Network Communication 3] Advantech Gateway Modbus Service Settings

GP 6 overall architecture study notes

This 985 professor is on fire!After 10 years of Ph.D. supervisor, no one has graduated with a Ph.D.!

flyway的快速入门教程

Unity 之 音频类型和编码格式介绍
Cache and Database Consistency Solutions
随机推荐
AcWing 1282. Search Keyword Problem Solution ((AC Automata) Trie+KMP)+bfs)
2022年Android 面经总结(附含面试题 | 源码 | 面试资料)
UVM RAL模型和内置seq
并发性,时间和相对性
10 Ways to Keep Your Interface Data Safe
adb shell 报错error: device unauthorized
Unity 之 音频类型和编码格式介绍
Bika LIMS 开源LIMS集—— SENAITE的使用(检测流程)
MySQL common statements
【愚公系列】2022年07月 Go教学课程 020-Go容器之数组
useragent怎么获取
adb shell error error: device unauthorized
go记录之——slice
flyway的快速入门教程
Automated testing - web automation - first acquaintance with selenium
九齐ny3p系列语音芯片替代国产方案KT148A性价比更高420秒长度
Golang 小数操作之判断几位小数点与四舍五入
cas与自旋锁(轻量级锁就是自旋锁吗)
淘宝/天猫获得淘口令真实url API
【AcWing】第 62 场周赛 【2022.07.30】