vuejs how to use mixin in single file component - vuejs
phpcn_u1582
phpcn_u1582 2017-05-16 13:42:10
0
2
607
  1. How to use mixing in a single Vue file? I have now written a change arrow method that I want to use in multiple files. I want to use it in other components through mixing. But I don’t know how to achieve it. Is there any other method?

phpcn_u1582
phpcn_u1582

reply all(2)
给我你的怀抱

Hybrid implementation 1.js

export default {
    methods:{
        changeArrow(){

        }
    }
}

Using Mix 2.js

import changeArrowMixin from './1'
export default {
    mixins: [changeArrowMixin]
}
世界只因有你

Introduce index.js under the mixins folder into the entry file

import mixins from './mixins'
Vue.mixin(mixins) //全局混合

In this way, the methods in the index can be called in every page

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template