当前位置:网站首页>Uni app essay
Uni app essay
2022-06-13 08:44:00 【Dependency_ Lai】
Get user rights
// Get user information
uni.getUserProfile({
desc: ' Sign in ', // This parameter is required
lang: 'zh_CN', // Return Chinese information
success: (infoRes) => {
console.log(infoRes.userInfo)
},
fail: (error) => {
console.log(error)
}
})
infoRes.userInfo Parameters :
Page Jump
1、navigateTo, Keep the current page , The page will display by default after jump ‘ return ’ Button , Click to return to the current page
Be careful :url Limited length , Too long will cause parameter transfer failure , You can use encodeURIComponent How to solve .
encodeURIComponent(JSON.stringify(data))
// With no arguments
uni.navigateTo({
url:"../../pages-merchants/pages/home/Home"})
// With parameters
uni.navigateTo({
url:"../../pages-merchants/pages/home/Home?index=1 && data=" + encodeURIComponent(JSON.stringify(data))})
// Receiving parameters
onLoad: function (option) {
//option by object type , Will serialize the parameters passed from the previous page
console.log(option.index); // Print out the parameters passed from the previous page .
console.log(JSON.parse(decodeURIComponent(option.data)); // Print out the parameters passed from the previous page .
}
2、 Tag jump , The method of parameter transmission is the same as above
<navigator url="/pages/index/Index" open-type="navigate">
<view> Point me to jump </view>
</navigator>
3、reLaunch, Close current page , The page will display by default after jump ‘ home page ’ Button , Click to return to the home page
uni.reLaunch({
url:"../../pages-merchants/pages/home/Home"})
Add... To the new page hideHomeButton The home button can be hidden
onShow() {
uni.hideHomeButton({
success: function() {
console.log(' Hide Home Button ')
}
})
}
4、switchTab, Close all other non tabBar page , Jump to tabBar page ,
uni.switchTab({
url: '/pages/index/Index'
});
5、redirectTo, Close current page , The page will display by default after jump ‘ return ’ Button , Click to return to the previous page
uni.redirectTo({
url: '/pages/index/Index'
});
6、navigateBack, Close current page , Go back to the previous page or multi-level page
uni.navigateBack({
delta: 1 // Number of pages returned
});
Dynamically set the page title
onLoad(options) {
uni.setNavigationBarTitle({
title: options.id ? ' Add receiving address ' : ' Edit shipping address '
});
},
image label
image label Default width 300px,height225px, Set up mode You can customize the cropping or scaling mode , Prevent the picture from stretching and deforming
Call the mobile phone to make a call
uni.makePhoneCall({
phoneNumber: phone, // cell-phone number
// Successful callback
success: (res) => {
console.log(' Successful call !')
},
// Failed callback
fail: (res) => {
console.log(' Call failed !')
this.call_phone();// Repeat the call
}
Call wechat map
1、 Check the location
uni.openLocation({
latitude: data.latitude, // dimension , -90 ~ 90
longitude: data.longitude // longitude , -180 ~ 180
});
2、 Select location
uni.chooseLocation({
// The default open location
latitude: data.latitude,
longitude: data.longitude,
success: function (res) {
console.log(res)
}
});
3、 Get current location
uni.getLocation({
type: 'wgs84',
success: function (res) {
console.log(res)
}
});
storage cache
// Store user information in the cache
uni.setStorage({
key: 'userInfo',
data: infoRes.userInfo,
success: function () {
// Authorized success , Go to other pages
uni.navigateTo({
url:"../../pages-merchants/pages/home/Home"
})
}
});
// Use user information
uni.getStorage({
key: 'userInfo',
success: (res) => {
this.userInfo = res.data;
}
});
Prompt box
uni.showToast({
title:" Successful release "
})
uni.showModal({
title: ' Tips ',
content: ' Confirm to delete the product ?',
confirmColor: '#2979ff',
cancelText: " Cancel ", // Cancel button text
confirmText: " confirm ", // Confirm button text
showCancel: true, // Whether to display the Cancel button , The default is true
confirmColor: '#f55850',
cancelColor: '#39B54A',
success: (res) => {
if (res.confirm) {
}else{
}
}
});
边栏推荐
- Form exercise 2
- 京东商品详情接口,京东详情页接口,宝贝详情页接口,商品属性接口,商品信息查询,商品详细信息接口,h5详情,京东APP详情,京东api接口,京东历史价格数据接口代码对接分享
- When submitting the laravel admin form and using the required verification, an error is reported when the value is 0
- Learning record 4:einops / / cudnn benchamark=true // hook
- Dest0g3 520 orientation
- CentOS installing MySQL and setting up remote access
- Request alarm: refer policy: strict origin when cross origin or reference site policy: no refer when downgrade
- 【Pycharm踩坑记录】配置远程运行后提示,[Errno 2] No such file or directory
- Object array de encapsulation
- File upload JS
猜你喜欢
Disk management and disk partition operation
JS array using the reduce() method
Use of addeventlistener in JS
JS - set countdown for Date object case
DIY UAV (anonymous controller p2+f330 rack)
About RSA encryption and decryption principle
5. Attribute selector
0.一些自己初学Solidworks的疑惑
JS - print 99 multiplication table of the for cycle case
DIY无人机(匿名拓控者P2+F330机架)
随机推荐
Process and scheduled task management
8、 JS data type conversion
1.SolidWorks各模块的学习顺序
Call to undefined function think\captcha\imagettftext()
redis
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案
CentOS installing MySQL and setting up remote access
2020-12-28
À propos des principes de chiffrement et de décryptage RSA
Time and date processing in JS
Use of addeventlistener in JS
Mobile terminal development I: basic concepts
关于RSA加密解密原理
0. some doubts about learning SolidWorks for the first time
Batch package and download Alibaba OSS files
Browser render passes
I set up a blog
Penetration problem (main directory, password explosion, database uploading Trojan horse)
DIY无人机(匿名拓控者P2+F330机架)
Namespace in TS (1)