userRouter
- 继承微信小程序 wx.switchTab =>
router.switchTab - 继承微信小程序 wx.reLaunch =>
router.reLaunch - 继承微信小程序 wx.redirectTo =>
router.replace - 继承微信小程序 wx.navigateTo =>
router.push - 继承微信小程序 wx.navigateBack =>
router.back - 扩充
router.go(-1), 只支持往后返回
ts
import { definePage, ref, useRouter } from '@52css/mp-vue3'
definePage({
queries: {
},
setup(query) {
const router = useRouter();
// 跳转方式1,支持path和query
const goPiniaTap = () => {
router.push({
path: '/pages/pinia/pinia',
query: {
a: 1,
b: 2
}
})
}
// 跳转方式2,原生url
const goPiniaTap2 = () => {
router.push({
url: '/pages/pinia/pinia?a=1&b=2',
})
}
// 跳转方式3,支持string
const goPiniaTap3 = () => {
router.push('/pages/pinia/pinia?a=1&b=2')
}
return {
goPiniaTap,
}
}
})