VUE - install 方式插件的使用

VUE - install 方式插件的使用

 

 1. 创建 VUE 项目

vue create vueplug

 

项目初始化结构

 

 

2. 创建 modules 文件夹,用于存放自定义插件

3. 在 modules 中创建 插件文件:Cmponent.vue

复制代码
<template>
  <div>组件</div>
</template>

<script>
export default {};
</script>

<style scoped>
</style>
复制代码

 

 

4. 在 modules 中创建 插件文件:index.js

 在这个文件中使用install方法来全局注册该组件

复制代码
import component from './Cmponent.vue';

const component = {
    install: function (Vue) {
        Vue.component('component', component)
    }
}

export default component;
复制代码

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

引用:https://wenku.baidu.com/view/2494d2005a0102020740be1e650e52ea5518ce2b.html

 

posted @   无心々菜  阅读(371)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示