反馈
wx.showToast({
//提示文字内容
title: '已发送',
//icon图标
icon: 'success',
//提示框出现时长
duration: 1500
})
wx.showModal({
title: '提示',
content: '这是一个模态弹窗',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
// 异步存储
wx.setStorage({
key:'list',
data:{name:'小明'}
})
// 同步存储
wx.setStorageSync({'key',{name:'小明'}})
// 异步操作
wx.getStorage({
key: 'list',
success(res){
console.log(res);
}
})
// 同步操作
const list = wx.getStorageSync('key')
// 保留当前页面,只能打开非 tabBar 页面。
wx.navigateTo({
url: 'test?id=1',
})
// 关闭卸载当前页面,只能打开非 tabBar 页面。
wx.redirectTo({
url: 'test?id=1'
})
// 关闭所有非tabbar页面, 只能打开 tabBar 页面。
wx.switchTab({
url: '/index'
})
// 关闭卸载所有页面,可以打开任意页面。
wx.reLaunch({
url: 'test?id=1'
})