当前位置:网站首页>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;
边栏推荐
- ThreadLocal
- adb shell error error: device unauthorized
- [pytorch] pytorch automatic derivation, Tensor and Autograd
- mysql的备份表的几种方法
- flowable工作流所有业务概念
- Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)
- Golang 切片删除指定元素的几种方法
- 京东获取商品历史价格信息 API
- Get Douyin Video Details API
- Masterless replication system (1) - write DB when node fails
猜你喜欢

Combinatorics Notes (6) Associative Algebra of Locally Finite Partially Ordered Sets, Möbius Inversion Formula

MySQL---多表查询

ThreadLocal

AcWing 1282. Search Keyword Problem Solution ((AC Automata) Trie+KMP)+bfs)

【码蹄集新手村600题】通向公式与程序相结合

Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)

Flex布局详解

After Effects 教程,如何在 After Effects 中调整过度曝光的快照?

After Effects tutorial, How to adjust overexposed snapshots in After Effects?

35 MySQL interview questions and diagrams, this is also easy to understand
随机推荐
go mode tidy出现报错go warning “all“ matched no packages
Flutter set the background color of the statusbar status bar and APP method (AppBar) internal consistent color.
新型电信“套路”,我爸中招了!
Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)
Flutter gets the height of the status bar statusbar
[Source code analysis] BeanFactory and FactoryBean
每日练习------随机产生一个1-100之间的整数,看能几次猜中。要求:猜的次数不能超过7次,每次猜完之后都要提示“大了”或者“小了”。
The server encountered an internal error that prevented it from fulfilling this request的一种解决办法[通俗易懂]
Concurrency, Timing and Relativity
MySQL---operator
adb shell 报错error: device unauthorized
保证接口数据安全的10种方式
MySQL---聚合函数
Taobao/Tmall get Taobao password real url API
Kotlin协程:续体、续体拦截器、调度器
如何识别假爬虫?
认识异常 (看完这篇你就懂了)
Go basic part study notes
INeuOS industrial Internet operating system, the equipment operational business and "low code" form development tools
Golang 切片删除指定元素的几种方法