赞
踩
一、页面相关API
uni.navigateTo({
url: '/pages/detail/detail?id=1'
})
uni.redirectTo({
url: '/pages/detail/detail?id=1'
})
pages.json
中配置的。uni.switchTab({
url: '/pages/index/index'
})
uni.reLaunch({
url: '/pages/index/index'
})
uni.navigateBack({
delta: 1
})
二、网络请求API
uni.request({
url: 'https://api.example.com',
method: 'GET',
data: {
id: 1
},
success: (res) => {
console.log(res.data)
},
fail: (err) => {
console.log(err)
}
})
uni.uploadFile({
url: 'https://api.example.com',
filePath: 'path/to/file',
name: 'file',
success: (res) => {
console.log(res.data)
},
fail: (err) => {
console.log(err)
}
})
uni.downloadFile({
url: 'https://example.com/file',
success: (res) => {
console.log(res.tempFilePath)
},
fail: (err) => {
console.log(err)
}
})
三、媒体相关API
uni.chooseImage({
count: 1,
success: (res) => {
console.log(res.tempFilePaths)
},
fail: (err) => {
console.log(err)
}
})
uni.previewImage({
urls: ['image1.jpg', 'image2.jpg'],
current: 'image1.jpg'
})
uni.saveImageToPhotosAlbum({
filePath: 'image.jpg',
success: () => {
console.log('保存成功')
},
fail: (err) => {
console.log(err)
}
})
四、地理位置相关API
uni.getLocation({
type: 'wgs84',
success: (res) => {
console.log(res.latitude, res.longitude)
},
fail: (err) => {
console.log(err)
}
})
uni.openLocation({
latitude: 39.9,
longitude: 116.4,
name: '北京市',
address: '朝阳区'
})
五、设备相关API
uni.getSystemInfo({
success: (res) => {
console.log(res.model, res.platform)
},
fail: (err) => {
console.log(err)
}
})
uni.scanCode({
success: (res) => {
console.log(res.result)
},
fail: (err) => {
console.log(err)
}
})
uni.makePhoneCall({
phoneNumber: '10086'
})
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。