Blogger Information
Blog 42
fans 0
comment 0
visits 15335
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0805组件注册的二种方式
小言
Original
315 people have browsed it

组件注册的二种方式,分别是全局组件和局部组件

全局组件提前声明,然后在任意子组件中都可以直接使用该组件,不需要在进行引入声明

  1. 全局注册
  2. const app = Vue.createApp();
  3. app.component('button-counter', {
  4. template: '#counter',
  5. data(){
  6. return{
  7. count: 0,
  8. };
  9. },
  10. });
  1. 局部组件
  2. const app = Vue.createApp({
  3. components: {
  4. buttonCounter :{
  5. template: '#counter',
  6. data(){
  7. return{
  8. count: 0,
  9. };
  10. },
  11. },
  12. },
  13. });

局部组件的意思就很简单,就是指只有引入的局部才可以使用这个组件,如果没有引入不可以使用。

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!