【问题标题】:How to change the logotip of pages when using vue-router?使用 vue-router 时如何更改页面的 logotip?
【发布时间】:2022-01-23 12:42:06
【问题描述】:

data() {强调文本 返回 { 可见:假, }; },

【问题讨论】:

    标签: vue.js vue-router


    【解决方案1】:

    您可以在组件中将手表添加到您的路由器,所以:

    <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,
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-01-09
      • 2019-08-15
      • 2020-12-11
      • 2020-12-15
      • 2018-06-03
      • 2020-09-21
      • 2018-10-27
      • 1970-01-01
      • 2019-05-25
      相关资源
      最近更新 更多