局部组件 : 导入的这个MyCom组件 , 只能在当前组件中使用
import MyCom from './MyCom'
export default {
components: { MyCom }
}
全局组件 : 在main.js中设置
import MyCom from './Mycom'
// Vue.component(组件名,组件)
Vue.component('MyCom', MyCom)
局部指令 :自定义的指令只能在当前组件生效
export default {
directives: {
focus: {
inserted(el){
el.focus()
}
}
}
}
全局指令 : 在main.js中设置
Vue.directive('focus', {
inserted(el){
el.focus()
}
})