this.setData({
isTap:true
});
console.log(JSON.stringify(e) );
//显示加载框
wx.showLoading({
title: '加载中',
})
//隐藏加载框
wx.hideLoading()
wx.showToast({
title: '功能暂未开放!',
icon: 'none', success
duration: 2000
})
setTimeout(function () {
wx.hideLoading()
}, 2000)
//1.设置缓存
wx.setStorageSync('key', 'value')
//2.获取缓存
wx.getStorageSync('key')
//3.移除缓存
wx.removeStorage({
key: 'key',
success: function(res) {
console.log(res.data)
}})
4.清除缓存
wx.clearStorage()
wx.showModal({
title: '复制该链接',
content: '完成后请手动打开浏览器,是否继续?' + link,
success: function (res) {
if (res.confirm) {
wx.setClipboardData({
data: link,
success: function () {
wx.showToast({
title: '复制成功',
duration: 1500,
})
},
fail: function () {
wx.showToast({
title: '复制失败',
icon: 'none',
duration: 500,
})
}
})
} else if (res.cancel) {
wx.showToast({
title: '取消复制',
icon: 'none',
duration: 500,
})
}
}
})
wx.setNavigationBarTitle({
title: '当前页面'
}
1.声明式导航 传参:通过query路径拼接方式
导航到tabBar页面
<navigator url="/pages/message/message" open-type="switchTab">导航到消息页面</navigator>
utl:跳转地址 必须以/开头
open-type:跳转方式 必须switchTab
导航到非tabBar页面
<navigator url="/pages/info/info" open-type="navigate">导航到info页面</navigator>
utl:跳转地址 必须以/开头
open-type:跳转方式 必须navigate 该属性可以省略
后退导航
<navigator open-type="navigateBack">后退</navigator>
open-type 属性值: navigateBack
delta number 后退层级 默认值为1
2.编程式导航 传参通过query路径拼接
<button bindtap="gotoMessage">跳转到消息页面</button>
跳转到tabBar页面
gotoMessage(){
wx.switchTab({
url:"/pages/message/message"
})
}
跳转到非tabBar页面
gotoMessage(){
wx.navigateTo({
url:"/pages/message/message"
})
}
后退导航
<button bindtap="goBack">跳转到消息页面</button>
goBack(){
wx.navigateBack({
detail:1 //默认值为1 number
})
}
在页面的onLoad事件中可以获取传递的参数
onLoad:function(options){
//options 就是传递过来的参数
console.log(options)
this.setData({
query:options
})//赋值到data中供页面使用
}
wx.getSystemInfo({
success: function(res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
}
})
wx.getLocation({
type: 'wgs84',
success: function(res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
}