$mount()手动挂载

当Vue实例没有el属性时,则该实例尚没有挂载到某个dom中;

假如需要延迟挂载,可以在之后手动调用vm.$mount()方法来挂载。例如:

new Vue({

//el: '#app',

router,

render: h => h(App)

// render: x => x(App)

// 这里的render: x => x(App)是es6的写法

// 转换过来就是: 暂且可理解为是渲染App组件

// render:(function(x){

// return x(App);

// });

}).$mount("#app");

或者

new Vue({

el: '#app',

router,

render: h => h(App)

// render: x => x(App)

// 这里的render: x => x(App)是es6的写法

// 转换过来就是: 暂且可理解为是渲染App组件

// render:(function(x){

// return x(App);

// });

});
new Vue({

  render: h=> h(App)

}). $mount(root)

Vue 2.0新增的函数,可以直接给绑定节点渲染一个vue组件,如果在Vue 1.x下,就应该使用

new Vue({
el: '#app',
components: { App }
});

然后在页面中写入标记:

<div id="app">
<app></app>
</div>

Vue render: h => h(App) $mount的更多相关文章

  1. new Vue({ render: h => h(App), }).$mount('#app')

    这里创建的vue实例没有el属性,而是在实例后面添加了一个$mount('#app')方法. $mount('#app') :手动挂载到id为app的dom中的意思 当Vue实例没有el属性时,则该实 ...

  2. 关于Vue中的 render: h => h(App) 具体是什么含义?

    render: h => h(App) 是下面内容的缩写: render: function (createElement) { return createElement(App); } 进一步 ...

  3. Vue中render: h => h(App)的含义

    // ES5 (function (h) { return h(App); }); // ES6 h => h(App); 官方文档 render: function (createElemen ...

  4. vue-cli: render:h => h(App)是什么意思

    import Vue from 'vue' import App from './App.vue' Vue.config.productionTip = false new Vue({ render: ...

  5. Vue2.0 render:h => h(App)

    new Vue({ router, store, //components: { App } vue1.0的写法 render: h => h(App) vue2.0的写法 }).$mount( ...

  6. render: h => h(App) $mount 什么意思

    初始一个vue.js项目时,常常发现main.js里有如下代码: new Vue({ render: h => h(App) }).$mount('#app') 这什么意思?那我自己做项目怎么改 ...

  7. vue中render: h => h(App)的详细解释

    2018年06月20日 10:54:32 H-L 阅读数 5369   render: h => h(App) 是下面内容的缩写:   render: function (createEleme ...

  8. 如何理解render: h => h(App)

    学习vuejs的时候对这句代码不理解 new Vue({ el: '#app', router, store, i18n, render: h => h(App) }) 查找了有关资料,以下为结 ...

  9. 解析vue2.0中render:h=>h(App)的具体意思

    render:h=>h(App)是ES6中的箭头函数写法,等价于render:function(h){return h(App);}. 注意点:1.箭头函数中的this是 指向 包裹this所在 ...

随机推荐

  1. iOS 一个ViewController上显示2个tableView的方法

    1.在StoryBoard上创建2个tableView,并用autolayout约束. 2.在ViewController上拖进来. @property (weak, nonatomic) IBOut ...

  2. Effective C++ Item 30 inline里里外外

    本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie Item 44 46 1.将大多数 inlining 限制在小型.被频繁调用的函数身上.这可 ...

  3. libsvm 的使用

    1. libsvm 支持的SVM模型 官网地址:LIBSVM – A Library for Support Vector Machines libsvm 支持的 SVM 模型如下(C:classif ...

  4. spring security源码分析心得

    看了半天的文档及源码,终于理出了spring-security的一些总体思路,spring security主要分认证(authentication)和授权(authority). 1.认证authe ...

  5. HTTP 各种特性应用(三)

    一. 数据协商 分类: 客户端请求: Accept: Accept:表明 我想要什么样的数据 Accept-Encoding:数据是什么样的编码方式 进行传输.主要限制 服务端怎样进行数据的压缩. A ...

  6. startActivityForResult and onActivityResult

    startActivityForResult and onActivityResult startActivityForResult 开启Activity 组织数据之后 发送,onActivityRe ...

  7. Java 学习(14):接口 & 包(设置 CLASSPATH 系统变量)

    Java 接口(英文:Interface) 定义:在JAVA编程语言中,接口是一个抽象类型,是抽象方法的集合,接口通常以 interface 来声明. 一个类通过继承接口的方式,从而来继承接口的抽象方 ...

  8. CODEVS——T 1404 字符串匹配

    http://codevs.cn/problem/1404/ 时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master 题解  查看运行结果     题目描述 Desc ...

  9. OpenStack_Swift源代码分析——Object-auditor源代码分析(2)

    1 Object-aduitor审计详细分析 上一篇文章中,解说了Object-aduitor的启动,当中审计的详细运行是AuditorWorker实现的.在run_audit中实例化了Auditor ...

  10. sql-server 2005数据库文件恢复(检測到基于一致性的逻辑 I/O 错误)

    今天sql-server数据库突然报错: SQL Server 检測到基于一致性的逻辑 I/O 错误 校验和不对(应为: 0x7c781313,但实际为: 0x67a313c9). 在文件 'C:\P ...