// Jump to the test.vue page on the start page and pass parameters
uni.navigateTo({
url: 'test?id=1&name=uniapp'
});
Close the current page and jump to a page in the app.
uni.redirectTo({
url: 'test?id=1'
});
关闭所有页面,打开到应用内的某个页面
uni.reLaunch({
url: 'test?id=1'
});
Jump to the tabBar page and close all other non-tabBar pages.
uni.switchTab({
url: '/pages/index/index'
});
Close the current page and return to the previous page or multi-level pages. You can get the current page stack through getCurrentPages() and decide how many layers you need to return.
uni.navigateBack({
delta: 2
});
Storing data in the specified key in the local cache will overwrite the original content corresponding to the key. This is an asynchronous interface.
uni.setStorage({
key: 'storage_key',
data: 'hello',
success: function () {
console.log('success');
}
});
A message box is displayed.
uni.showToast({
title: '标题',
duration: 2000
});
uni.hideToast() hides the message prompt box.
Display modal pop-up windows, similar to standard html message boxes: alert, confirm.
uni.showModal({
title: '提示',
content: '这是一个模态弹窗',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});