Vue--组件嵌套

1、全局注册:

组件放到components文件夹内,建议组件名是什么行为的name名就是什么

main.js

引入组件:import Users from '组件位置'

注册全局组件:Vue.component('users'(注册标签,使用这个标签来调用组件),Users(对应上面的引入组件));

在任何组件都可以调用;

2、局部组件:

在需要调用组件的页面先调用组件页面;

import User from '组件位置'

export default{

  name:'.....',

  ......

  components:{

    User  //使用这个字段的标签来获取组件的内容

  }

}

原文地址:https://www.cnblogs.com/xinchenhui/p/8658187.html