【vue开发】render的用法,全局引入/组件简化代码

在main.ts 中添加

Vue.component('sayHello',{   render(h){       return h('p',{         style:{           color:'red'         }       },`早上好`)//格式是`${this.userName}`     },   data(){     return{       userName:'小明'     }   } })
注意参数说明:h(标签,属性,值)

在各组件中使用

<sayHello></sayHello>

 

posted @ 2020-10-10 16:11  JeckHui  阅读(632)  评论(0编辑  收藏  举报