使用vue-router时如何更改页面的标识?
How to change the logotip of pages when using 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,
}
}
}
您可以在组件中将手表添加到您的路由器,因此:
<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,
}
}
}