【发布时间】:2022-01-23 12:42:06
【问题描述】:
data() {强调文本 返回 { 可见:假, }; },
【问题讨论】:
标签: vue.js vue-router
data() {强调文本 返回 { 可见:假, }; },
【问题讨论】:
标签: vue.js vue-router
您可以在组件中将手表添加到您的路由器,所以:
<template>
<div>
<img v-if="visible" :class="{logoB:visible}" src="@/assets/images/svg/logo-footer.svg" />
</div>
</template>
这里是脚本部分
export default {
name: "MyComponent",
data() {
return {
visible: false
}
},
watch: {
$route: {
handler: function(to) {
this.visible = to.name === 'my-awesome-route';
},
immediate: true,
}
}
}
【讨论】: