Home > Mobile >  How to change the logotip of pages when using vue-router?
How to change the logotip of pages when using vue-router?

Time:12-23

<img v-if="visibl" : src="@/assets/images/svg/logo-footer.svg" alt=":(/>

data() {emphasized text return { visible: false, }; },

CodePudding user response:

You can add watch to your router in component, So:

<template>
<div>
    <img v-if="visible" : src="@/assets/images/svg/logo-footer.svg" />
</div>
</template>

script part here

export default {
    name: "MyComponent",
    data() {
        return {
            visible: false
        }
    },
    watch: {
        $route: {
            handler: function(to) {
                this.visible = to.name === 'my-awesome-route';
            },
            immediate: true,
        }
    }
}
  • Related