1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
export default { install(Vue, options) { console.log('install 插件'); console.log('options', options); Vue.prototype.pluginMethod = function (value) { console.log('invoke plugins myMethod'); console.log('myMethod param value', value); }; Vue.prototype.pluginPrototype = 'odinsam plugins'; Vue.filter('odinFilter', function (value) { console.log('odinFilter 被调用'); return value + '-odinFilter 被调用'; }); Vue.directive('big', { bind(ele, binding) { console.log( '1次调用 - 当指令与元素绑定成功时调用,在内存,页面并没有元素' ); console.log('binding', binding); ele.innerText = 'v-big指令显示' + binding.value; }, inserted(ele, binding) { console.log('1或n次调用 - 指令所在的元素被插入页面时调用'); }, update(ele, binding) { console.log('1或n次调用: 当指令所在模板被重新解析时'); } }); Vue.mixin({ data() { return { pluginMixinValue: 'plugins mixin data' }; } }); } };
|