问题描述:

main.js

import Vue from 'vue'
import App from './App' /* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})

为什么已经定义了 components: { App } ,还需要 template: '<App/>' ?

问题解答:

el: '#app' :是指向 index.html 的<div id="app"></div>元素,该元素作为vue的挂载点

components :是声明有哪些组件

template : 是使用哪个组件

将 <App/> 挂载到 #app 这个元素,<App/> 本身是一个组件,即这里通过 components: { App } 注册组件,然后通过 template: '<App/>' 使用组件。

最新文章

  1. Chrome出了个小bug:论如何在Chrome下劫持原生只读对象
  2. 初识HTML
  3. jekins构建自动化项目的步骤
  4. Linux 多线程信号量同步
  5. 利用K-means聚类分类,进行特征学习
  6. Android 和iOS 创建本地通知
  7. APT 常用功能
  8. html5 meta头部设置
  9. 从ASM迁移到ARM(1):平台支持的迁移服务
  10. 打包程序时的证书问题(上传APP就出现Missing iOS Distribution signing indetity for)
  11. python 中如何导入一个自己创建的模块
  12. MySQL 如何存储长度较大的varchar与blob
  13. linux(四)之元字符
  14. 自定义alert窗口样式
  15. JavaSE:数据类型之间的转换(附常见面试题)
  16. Mysql 字符串分隔函数
  17. org.apache.commons.vfs 配置文件里面 密码包含 @
  18. redhat7通过yum安装nginx最新版
  19. 文末有福利 | IT从业者应关注哪些技术热点?
  20. debian 安装使用NTP

热门文章

  1. samb共享
  2. SpringMVC学习记录三——8 springmvc和mybatis整合
  3. 数字图像处理学习笔记之一 DIP绪论与MATLAB基础
  4. 【luogu P2065 [TJOI2011]卡片】 假题解
  5. 数据库——MySQL——多表查询
  6. Spring知识点总结(一)
  7. 微信小程序学习笔记(一)
  8. Angularjs基础(七)
  9. Invalid default value for prop &quot;value&quot;: Props with type Object/Array must use a factory function to return the default value.(props default 数组/对象的默认值应当由一个工厂函数返回)
  10. ABAP术语-BAPI (Business Application Programming Interface)