当前位置:网站首页>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{
}
}
});
边栏推荐
- Learning record 4:einops / / cudnn benchamark=true // hook
- filebeat采集日志到ELK
- Replace jade engine with EJS
- VI editor
- Notes on MySQL transaction not automatically submitting
- Undefined and null in JS
- DHCP principle and configuration
- Vs installation of vassistx plug-in causes Chinese input of wpf-xaml file to be garbled. Solution
- JS - print 99 multiplication table of the for cycle case
- Batch package and download Alibaba OSS files
猜你喜欢
4、 Js-es5-i / O
Penetration problem (main directory, password explosion, database uploading Trojan horse)
SQL injection question type (manual injection +sqlmap)
JS - set countdown for Date object case
Svg text stroke effect
useRoutes() may be used only in the context of a <Router> component.
WARNING:tornado.access:404 GET /favicon.ico (172.16.8.1) 1.84ms [附静态文件设置]
Sky background map, navigation page lovefanfan top
Remote access and control
About RSA encryption and decryption principle
随机推荐
Penetration problem (main directory, password explosion, database uploading Trojan horse)
Three methods to make the scroll bar of div automatically scroll to the bottom
redis.exceptions.ConnectionError: Error 111 connecting to 172.16.8.128:6379. Connection refused.
Installing pytorch under Anaconda
GBase 8a磁盤問題及處理
ADT Google browser plug-in ad Terminator
MySQL queries difference sets (missing data) by linking tables based on an associated field
GBase 8a磁盘问题及处理
JS ask for the day of the year
LVM management exercise
7、 JS data type
JS array method
Redis subscribe connection timeout interrupt problem solution
Vscode double shortcut keys up, down, left and right
filebeat采集日志到ELK
How to save the video of wechat video number locally?
Yarn package management tool
天猫商品详情接口,天猫商品优惠券接口,天猫api接口,天猫价格监控接口,天猫比价接口,品牌维权接口,天猫销量api接口,接口代码可对接数据分析业务,品牌维权,比价业务,行业分析业务接口代码分享
DHCP principle and configuration
VI editor