1.ConterContainer.vue
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22<template> <div class="conterContainer"> <slot></slot> </div> </template> <script> export default {}; </script> <style> .conterContainer { display: flex; display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; /* 子元素水平居中 */ -webkit-justify-content: center; justify-content: center; -moz-box-pack: center; } </style>
2.index.js
复制代码
1
2
3
4
5
6
7import ConterContainer from './components/ConterContainer.vue' export default { install: (Vue) => { Vue.component('ConterContainer', ConterContainer) } }
3.main.js
复制代码
1
2
3import Plugin from '@/plugin/index.js'; Vue.use(Plugin);
4.可以直接在vue组件中使用了
复制代码
1
2
3
4
5
6
7
8
9<template> <ConterContainer> <h2></h2> </ConterContainer> </template> <script> export default {}; </script>
最后
以上就是暴躁故事最近收集整理的关于Vue.component封装组件并注册使用的全部内容,更多相关Vue内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复