current position:Home>Mixed mixin of Vue

Mixed mixin of Vue

2022-04-29 06:32:38We long for a different world

Mixing is to realize the sharing and reuse of multi method data in the component

1. How do you use it? mixin

{ {msg}}
<script>
  var mixin = {
    
    data() {
    
      return {
    
        msg: " I'm mixed data "
      }
    },
    creatre: function() {
    
    }
  }
  export default {
    
    name: 'app_download',
    mixins: [mixin],
    data() {
    
      return {
    
      }
    },
    methods: {
    },
    created() {
    },
    mounted() {
    },
  }
</script>

 Insert picture description here

You can see that we can get mixin Isn't it amazing that the data is , So here comes the question , What will happen if the data method we mixed in conflicts with its own components

 Insert picture description here
 Insert picture description here

 The results are clear , The advantages of mixing can realize the data differentiation and sharing methods of different components , But the bad thing is that if there are too many operation methods, it is easy to name conflicts or cause multiple execution of methods 

copyright notice
author[We long for a different world],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204260938538006.html

Random recommended