示例代码:
//main.ts
import { createApp } from 'vue';
import ArcoVue from '@arco-design/web-vue';
import ArcoVueIcon from '@arco-design/web-vue/es/icon';
import globalComponents from '@/components';
import Captcha from "@kkokk/captcha"
import router from './router';
import store from './store';
import directive from './directive';
import {ConvertDate3,ConvertDate4} from '@/utils/timeformat.js'
import {formatNumber} from './utils/price.js'
import App from './App.vue';
import '@/assets/style/global.less';
import '@/api/interceptor';
import useAppStore from '@/store/modules/tab-bar/index'
const app = createApp(App);
app.config.globalProperties.$baseUrl = import.meta.env.VITE_API_BASE_URL;
app.config.globalProperties.$resourceUrl = import.meta.env.VITE_API_BASE_URL;
app.config.globalProperties.$ConvertDate3 = ConvertDate3;
app.config.globalProperties.$ConvertDate4 = ConvertDate4;
app.config.globalProperties.$formatNumber = formatNumber;
app.use(ArcoVue, {});
app.use(ArcoVueIcon);
app.use(store);
const originalBack = router.back;
const tabbarStore = useAppStore();
router.back= () => {
console.log(tabbarStore);
const route = router.currentRoute.value
//@ts-ignore
const index = tabbarStore.getTabList.indexOf(route.name)
//@ts-ignore
index && tabbarStore.deleteTag(index,route)
originalGo.call(router);
};
app.use(router);
app.use(globalComponents);
app.use(directive);
app.use(Captcha)
app.mount('#app');
为了实现返回的时候把 tag 标签删了
这样只要调用 router.go(-1) 的时候就会自己把标签删了
注:可以自行调整,因为刚刚写好不知道有没有其他问题