github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/vue-1.0.24/src/directives/element/partial.js (about) 1 import vIf from '../public/if' 2 import FragmentFactory from '../../fragment/factory' 3 import { PARTIAL } from '../priorities' 4 import { 5 createAnchor, 6 replace, 7 resolveAsset 8 } from '../../util/index' 9 10 export default { 11 12 priority: PARTIAL, 13 14 params: ['name'], 15 16 // watch changes to name for dynamic partials 17 paramWatchers: { 18 name (value) { 19 vIf.remove.call(this) 20 if (value) { 21 this.insert(value) 22 } 23 } 24 }, 25 26 bind () { 27 this.anchor = createAnchor('v-partial') 28 replace(this.el, this.anchor) 29 this.insert(this.params.name) 30 }, 31 32 insert (id) { 33 var partial = resolveAsset(this.vm.$options, 'partials', id, true) 34 if (partial) { 35 this.factory = new FragmentFactory(this.vm, partial) 36 vIf.insert.call(this) 37 } 38 }, 39 40 unbind () { 41 if (this.frag) { 42 this.frag.destroy() 43 } 44 } 45 }