Vue Mixins Configure

Created
Created
2021 Apr 13 2:11
Refs
// mixin 객체 생성 var myMixin = { created: function () { this.hello() }, methods: { hello: function () { console.log('hello from mixin!') } } } // mixin을 사용할 컴포넌트 정의 var Component = Vue.extend({ mixins: [myMixin] }) var component = new Component() // => "hello from mixin!"
 
 
var mixin = { data: function () { return { message: 'hello', foo: 'abc' } } } new Vue({ mixins: [mixin], data: function () { return { message: 'goodbye', bar: 'def' } }, created: function () { console.log(this.$data) } })
 
 
 
 

Recommendations