当前位置:网站首页>全局components组件注册
全局components组件注册
2022-07-29 05:09:00 【程序Ms_Wqh】
1.再components目录下创建一个index.js文件

2.在index.js 引入要全局注册的组件并导出
vue提供install可供我们开发新的插件及全局注册组件等
install方法第一个参数是vue的构造器,第二个参数是可选的选项对象
//引入要全局注册的组件
import MyForm from './MyForm'
import MyHeader from './MyHeader'
import MyAside from './MyAside'
import MyMain from './MyMain'
import Breadcrumb from './Breadcrumb'
import MyDialog from './MyDialog'
import MyTable from './MyTable'
import ContentLayout from '../../layouts/ContentLayout'
export default {
install(Vue) {
[MyTable,MyDialog,ContentLayout,Breadcrumb,MyForm,MyHeader,MyAside,MyMain].forEach(item=> Vue.component(item.name,item))
}
}Vue.component(item.name,item) 第一个参数是组建的名称 第二个是导入的组件
详细使用说明可见官网:API — Vue.js
3.在main.js导入
官方对 Vue.use() 方法的说明:通过全局方法 Vue.use() 使用插件
import Components from '@/components/index' //引入刚创建的注册文件
Vue.use(Components)
边栏推荐
- 365 day challenge leetcode 1000 questions - day 037 elements and the maximum side length of squares less than or equal to the threshold + the number of subsequences that meet the conditions
- 整数溢出和打印
- Cmu15-213 malloc lab experiment record
- Occt learning 001 - Introduction
- JD cloud golden autumn cloud special offer is in progress! Code scanning participation activities
- APP常用跨端技术栈深入分析
- QT series - Installation
- 抢先预约 | 阿里云无影云应用线上发布会预约开启
- How rimworld uploads creative workshops through steamcmd
- 2022数学建模竞赛暑期培训讲座——最优化方法:目标规划
猜你喜欢

Come on! See how Clickhouse, which has risen 16 places a year, can be implemented in jd.com

365 day challenge leetcode 1000 questions - day 037 elements and the maximum side length of squares less than or equal to the threshold + the number of subsequences that meet the conditions

【剑指offer】— 详解库函数atoi以及模拟实现atoi函数

321,京东言犀×NLPCC 2022挑战赛开赛!

Alibaba cloud and Dingjie software released the cloud digital factory solution to realize the localized deployment of cloud MES system

In depth analysis of common cross end technology stacks of app

JD cloud and Forrester consulting released a hybrid cloud report that cloud Nativity has become a new engine driving industrial development

Helm chart for Kubernetes

Helm chart for Kubernetes

阿里云架构师梁旭:MES on 云盒,助力客户快速构建数字工厂
随机推荐
D3d Shader Instruction
阿里云架构师梁旭:MES on 云盒,助力客户快速构建数字工厂
C语言 一维数组
Introduction to array learning simple question sum of two numbers
副作用和序列点
Allocate memory: malloc() and free()
【C语言系列】—深度解剖数据在内存中的存储(二)-浮点型
小程序中的DOM对象元素块动态排序
Best practices for elastic computing in the game industry
终端shell常用命令
Yangyonglin, vice president of Rushi Technology: when traditional industries encounter "digital space"
【C语言系列】— 一道递归小题目
365天挑战LeetCode1000题——Day 041 二分查找完结纪念 + 第 N 个神奇数字 + 在线选举
[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises
CMU15-213 Shell Lab实验记录
阿里云张新涛:异构计算为数字经济提供澎湃动力
365天挑战LeetCode1000题——Day 035 每日一题 + 二分查找 13
Teardown's method of lifting the time limit
抢先预约 | 阿里云无影云应用线上发布会预约开启
365 day challenge leetcode 1000 questions - day 041 two point search completion anniversary + nth magic number + online election