zoukankan      html  css  js  c++  java
  • Vue基础 の render() 函数

     
        <div id="app"></div>
        <script>
            const root = Vue.createApp({
                template:`
                    <div> 
                      <my-title :level='2'>
                        hey
                      <my-title/>
                      
                    </div>
                `
            })
            //定义 全局组件
            root.component('my-title',{
                props:['level'],
                template:` 
                    <h1 v-if='level === 1'> <slot/> </h1>
                    <h2 v-if='level === 2'> <slot/> </h2>
                `
            })
            root.mount('#app')
        </script>
    View Code

    render(){ } 使用

    <body>
        <div id="app"></div>
        <script>
            const root = Vue.createApp({
                template:`
                    <div> 
                      <my-title :level='2'>
                        hey
                      <my-title/>
                    </div>
                `
            })
            //定义 全局组件
            root.component('my-title',{
                props:['level'],
                render(){
                    //h函数
                    const {h} = Vue;
                        //第一个参数标签名 , 第二个参数标签的属性 , 第三个参数 数组,字符串 床日
                    return h('h'+this.level,{}, this.$slots )
                }
            })
            root.mount('#app')
        </script>
    </body>
    View Code
    <body>
        <div id="app"></div>
        <script>
            const root = Vue.createApp({
                template:`
                    <div> 
                      <my-title :level='2'>
                        hey
                      <my-title/>
                    </div>
                `
            })
            //定义 全局组件
            root.component('my-title',{
                props:['level'],
                render(){
                    //h函数
                    const {h} = Vue;
                        //第一个参数标签名 , 第二个参数标签的属性 , 第三个参数 数组,字符串 床日
                    return h('h'+this.level,{}, this.$slots )
                }
            })
            root.mount('#app')
        </script>
    </body>
  • 相关阅读:
    lc377完全背包问题
    lc650
    lc583
    java static序列化
    lc90回溯
    lc78回溯
    Java基础之常量池
    语法与语义
    数据结构之复杂度分析
    数据结构与算法前言
  • 原文地址:https://www.cnblogs.com/Hanro-Z/p/14586089.html
Copyright © 2011-2022 走看看