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

admin4年前vue242

render: h => h(App) 是下面内容的缩写:

进一步缩写为(ES6 语法):

再进一步缩写为:

按照 ES6 箭头函数的写法,就得到了:

其中 根据 Vue.js 作者 Even You 的回复,h 的含义如下:

It comes from the term "hyperscript", which is commonly used in many virtual-dom implementations. "Hyperscript" itself stands for "script that generates HTML structures" because HTML is the acronym for "hyper-text markup language".

它来自单词 hyperscript,这个单词通常用在 virtual-dom 的实现中。Hyperscript 本身是指 
生成HTML 结构的 script 脚本,因为 HTML 是 hyper-text markup language 的缩写(超文本标记语言)

个人理解:createElement 函数是用来生成 HTML DOM 元素的,也就是上文中的 generate HTML structures,也就是 Hyperscript,这样作者才把 createElement 简写成 h。

Vue.js 里面的 createElement 函数,这个函数的作用就是生成一个 VNode节点,render 函数得到这个 VNode 节点之后,返回给 Vue.js 的 mount 函数,渲染成真实 DOM 节点,并挂载到根节点上。


相关文章

vue2使用富文本编辑器

https://blog.csdn.net/m0_61257622/article/details/127331859...

vue实现数组上移下移置顶置底

swapItems: function(arr, index1, index2, direction) {             ...

vue滚动加载列表

new Vue({    el: '#app',    data: {  &n...

vue平滑到指定ID

this.$nextTick(() => {            document.getElementById('resu...

vue elementui动态生成表格数据

<el-table :data="tableData" border class="mb30">       ...

在VUE中使用swiper

npm i swiper<template>   <swiper     :slides-per-...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。