This commit is contained in:
@ -2,72 +2,12 @@
|
||||
import { router } from '@/router';
|
||||
|
||||
definePage({
|
||||
alias: '/'
|
||||
alias: '/',
|
||||
});
|
||||
|
||||
const testButtons = [
|
||||
{
|
||||
text: 'Page1 -> Page2',
|
||||
onClick: async () => {
|
||||
console.clear();
|
||||
console.debug('⚙️ 预期结果:', ['Page1', 'Page2']);
|
||||
await router.push({ name: 'Page1' });
|
||||
await router.push({ name: 'Page2' });
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'A -> (B) -> C',
|
||||
onClick: async () => {
|
||||
console.clear();
|
||||
console.debug('⚙️ 预期结果: ', ['Page1', 'Page3']);
|
||||
await router.push({ name: 'Page1' });
|
||||
await router.push({ name: 'Page2' });
|
||||
await router.push({ name: 'Page3', replace: true });
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'A -> B -> C -> go(-2)',
|
||||
onClick: async () => {
|
||||
console.clear();
|
||||
console.debug('⚙️ 预期结果: ', ['/', '/Page1📍', '/Page2', '/Page3']);
|
||||
await router.push({ name: 'Page1' });
|
||||
await router.push({ name: 'Page2' });
|
||||
await router.push({ name: 'Page3' });
|
||||
router.go(-2);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'A -> B -> C -> go(-1) -> (D)',
|
||||
onClick: async () => {
|
||||
console.clear();
|
||||
console.debug('⚙️ 预期结果: ', ['/', 'Page1', 'Page4📍', 'Page3']);
|
||||
await router.push({ name: 'Page1' });
|
||||
await router.push({ name: 'Page2' });
|
||||
await router.push({ name: 'Page3' });
|
||||
router.go(-1);
|
||||
|
||||
function popStateListener() {
|
||||
console.debug('back执行完成, 替换"Page2"为"Page4"');
|
||||
router.replace({ name: 'Page4' });
|
||||
window.removeEventListener('popstate', popStateListener);
|
||||
}
|
||||
|
||||
window.addEventListener('popstate', popStateListener);
|
||||
}
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-2 items-start">
|
||||
<div class="flex gap-2">
|
||||
<t-button @click="$router.push({ name: 'Page1' })">ToPage1</t-button>
|
||||
<t-button @click="$router.push({ name: 'Page2' })">ToPage2</t-button>
|
||||
<t-button @click="$router.push({ name: 'Page3' })">ToPage3</t-button>
|
||||
</div>
|
||||
|
||||
<template v-for="btn in testButtons" :key="btn.text">
|
||||
<t-button theme="primary" @click="btn.onClick">{{ btn.text }}</t-button>
|
||||
</template>
|
||||
<div>
|
||||
<h1>Index Page</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user