Is there any good idea for the components that every page has?

for example, if you want to add a fixed button to return to the home page, there are only one or two pages without it. You can make a component and write it in every vue file. But it doesn"t feel flexible, so if you want to delete this tag, you have to do it again on each page? Is there any good idea

Sep.20,2021

you can write in App.vue
eg:

<h1 @click="backFunc" v-if="$route.meta.back"></h1>
<router-view></router-view>
backFunc () {
    this.$router.go(-1)
}

router.js controls whether or not a page is required

{
      path: '/a',
      component: a,
      meta: {
        title: 'a',
        back:1
      }
    },
    {
      path: '/b',
      component: b,
      meta: {
        title: 'b',
        back:0
      }
    }

if you don't want to add it to every page, try nested child routing.
add: like the top menu with return key, it is best to use public components, which can be customized. If you don't want to use that tag, you can uniformly set it to be unavailable or invisible, etc. You don't have to delete every page.


if the location is fixed, you can write it outside the route, and then control the status through vuex

Menu