目录1、全局注册组件2、全局自定义指令Vue提供install可供我们开发新的插件及全局注册组件等 install方法第一个参数是vue的构造器,第二个参数是可选的选项对象 ex
Vue
提供install
可供我们开发新的插件及全局注册组件等
install
方法第一个参数是vue
的构造器,第二个参数是可选的选项对象
export default {
install(Vue,option){
组件
指令
混入
挂载vue原型
}
}
import PageTools from '@/components/PageTools/pageTools.vue'
import update from './update/index.vue'
import ImageUpload from './ImageUpload/ImageUpload.vue'
import ScreenFull from './ScreenFull'
import ThemePicker from './ThemePicker'
import TagsView from './TagsView'
export default {
install(Vue) {
Vue.component('PageTools', PageTools)
Vue.component('update', update)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ScreenFull', ScreenFull)
Vue.component('ThemePicker', ThemePicker)
Vue.component('TagsView', TagsView)
}
}
在main.js中直接用引用并Vue.use进行注册
import Component from '@/components'
Vue.use(Component)
export default{
install(Vue){
Vue.directive('pre',{
inserted(button,bind){
button.addEventListener('click',()=>{
if(!button.disabled){
button.disabled = true;
setTimeout(()=>{
button.disabled = false
},1000)
}
})
}
})
}
}
在main.js跟注册组件一样
import pre from '@/aiqi'
Vue.use(pre)
到此这篇关于 vue中install方法介绍的文章就介绍到这了,更多相关 vue中install方法内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: vue中install方法介绍
本文链接: https://www.lsjlt.com/news/158203.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0