// 第一步
<script>
import {defineComponent} from "vue";
export default defineComponent({
beforeRouteEnter(to, from, next) {
if (to.query.type == 'fix') {
to.meta.title = '修改动态标题'
}
next((e) => {
const data = '数据'
e.beforeRouteEnter(data)
});
}
})
</script>
// 第二步
<script setup>
const beforeRouteEnter = (data)=>{
// 进行操作
console.log(data)
}
defineExpose({
beforeRouteEnter,
});
</script>
【Vue3】setup语法糖中动态修改路由的meta.title
于 2024-03-04 16:06:48 首次发布