加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Vue中render方法的使用详解

发布时间:2020-12-17 02:37:11 所属栏目:百科 来源:网络整理
导读:先说一下对官网上demo的个人理解: div class="jb51code" pre class="brush:xhtml;" !DOCTYPE html Vue的render方法说明 script type="text/x-template" id="anchored-heading-template" script type="text/javascript" Vue.component('child',{ template: '#

先说一下对官网上demo的个人理解:

<div class="jb51code">
<pre class="brush:xhtml;">
<!DOCTYPE html>

Vue的render方法说明

<script type="text/javascript">
Vue.component('child',{
template: '#anchored-heading-template',props: {
level: {
type: Number,required: true
}
}
});
new Vue({
el: "#app"
})

虽然使用template定义组件的方法非常的直观,但是这样会造成代码过长。可以使用render的方法

<div class="jb51code">
<pre class="brush:xhtml;">
<!DOCTYPE html>

Vue的render方法说明

下面是一个slot具名分发的demo:介绍了creatElement的用法:

<div class="jb51code">
<pre class="brush:xhtml;">
<!DOCTYPE html>

Vue的render方法说明

所创建的组件的demo结果如下:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读