Can the mixins blending of vue achieve the global blending of some components?

for example, I have a two-level menu

user:{
    child:[
        {detail},
        {update}
    ]
}

order:{
    child:[
        {add},
        {delete}
    ]
}

I want to mix all the child routes under all user routes with a mounted;

cannot affect order routing,

I used global blending in main.js and found that even the third-party libraries I introduced would affect


vue does not provide a direct method, but it is not difficult to implement. A relatively simple way is to add judgment

to the global mixin method.

like this

Vue.mixin({
  mounted() {
    if (this.mixinActive) {
      console.log('mixin');
    }
  },
});

only data presets mixinActive: true in the component. Of course, this judgment can also be determined by this.$options.name to determine the component name, or this.$route to determine the route

.

Don't you just blend in locally at the user routing place?

// user
<script>
   export default {
        mixins: [xxx]
   }
</script>

Global mixin is global as its name implies, and your requirements in the problem description do not match the global, so you cannot use it in this way.

if you want to achieve a similar effect, use provide/inject dependency injection api provided by vue, which should meet the requirements of global injection dependency and local on-demand injection.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea5fd2-47b64.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea5fd2-47b64.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?