search

Home  >  Q&A  >  body text

vuejs how to use mixin in single file component - vuejs

  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_u1582phpcn_u15822756 days ago583

reply all(2)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:44:10

    Hybrid implementation 1.js

    export default {
        methods:{
            changeArrow(){
    
            }
        }
    }

    Using Mix 2.js

    import changeArrowMixin from './1'
    export default {
        mixins: [changeArrowMixin]
    }

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 13:44:10

    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

    reply
    0
  • Cancelreply