当前位置:网站首页>Remember a uniapp experience
Remember a uniapp experience
2022-07-28 19:02:00 【InfoQ】
Preface
pit :uView Component library ,uToast Components
// Put this tag on the page
<u-toast ref="uToast" />
// If you need a message , Add the following code
this.$refs.uToast.show({
title: ' Login successful ',
type: 'success',
url: '/pages/user/index'
})
title: The text displayed by the message prompt
type: Topic type , Default isdefault( Altogether 6 Medium theme color )
url:toast End jump url, Do not fill in or jump
About toast End jump URL
- If the
urlParameters , stay toast At the end , Will useuni.navigateTo( Default ) perhapsuni.switchTab( Additional settings are requiredisTabbytrue)
- If the
paramsParameters , It will automatically be in URL These parameters are spliced in the back , The usage is as follows :
this.$refs.uToast.show({
title: ' Successful operation ',
url: '/pages/user/index',
params: {
id: 1,
menu: 3
}
})
encapsulation uni.getStorage function
uni.getStorage({
key: 'storage_key',
success: function (res) {
console.log(res.data);
}
});
keyres.datakeyres.datauni.getStorage({
key: 'token',
success:(res) => {
console.log('token:'+ res.data)
this.token = res.data
}
})
uni.getStorage({
key: 'username',
success:(res) => {
console.log('username' + res.data)
this.userInfo.username = res.data
}
})
getCache(a){
let b = '';
console.log('a:'+a)
uni.getStorage({
key:a,
success:(res)=>{
console.log('res.data:'+res.data);
b = res.data;
return res.data;
}
})
return b;
},
let username = this.getCache('username')
Last
Improve the above encapsulation function
cache.js export function getCache(a){
let b = '';
console.log('a:'+a)
uni.getStorage({
key:a,
success:(res)=>{
console.log('res.data:'+res.data);
b = res.data;
return res.data;
}
})
return b;
}
import {getCache} from 'common/cache.js'
this.username = getCache('username')
边栏推荐
- A priori, a posteriori, likelihood
- How big is it suitable for learning software testing?
- Four years later, Debian finally recaptured the "debian.community" domain name!
- 配置教程:新版本EasyCVR(v2.5.0)组织结构如何级联到上级平台?
- Is the software testing training institution reliable?
- Gateway入门
- 3、 Uni app fixed or direct to a certain page
- 面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?
- What does real HTAP mean to users and developers?
- SwiftUI 组件之如何实现电话号码掩码隐藏部分的文本字段TextField(教程含源码)
猜你喜欢

My creation anniversary -- July 25th, 2022

Meta Q2 earnings: revenue fell for the first time, and metaverse will compete with apple

Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?

jvm四种引用类型

redis优势以及数据结构相关知识

Introduction and advanced MySQL (4)

How to adjust the brightness of win11? Four methods of adjusting screen brightness in win11

湖上建仓全解析:如何打造湖仓一体数据平台 | DEEPNOVA技术荟系列公开课第四期

How to break through the bottleneck of professional development for software testing engineers
![[actual combat] realize page distortion correction with OpenCV](/img/7b/7e25bde34a9d5463af3dd40599c80e.png)
[actual combat] realize page distortion correction with OpenCV
随机推荐
One Hot编码是什么?为什么要用它,什么时候用它?
QT with line encoding output cout
How long does software testing take?
Can zero basis software testing work?
My creation anniversary -- July 25th, 2022
How to adjust the brightness of win11? Four methods of adjusting screen brightness in win11
零知识证明:具有DDH假设的 ZKP
Pyqt5 rapid development and practice 5.3 multithreading
广告推荐CTR点击率预测实践项目!
Software testing dry goods
GC garbage collector details
Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?
历史上的今天:微软收购 QDOS;模型检测先驱出生;第一张激光照排的中文报纸...
2022年中国企业服务产业市场行情
How does the mqtt server built with emqx forward data and save it to the cloud database?
kotlin:Nothing
Redis advantages and data structure related knowledge
CTR click through rate prediction practice project of advertising recommendation!
AI 改变千行万业,开发者如何投身 AI 语音新“声”态
Mongodb initialization