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

在main.ts 中添加

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

在各组件中使用

<sayHello></sayHello>
原文地址:https://www.cnblogs.com/xiaohuizhang/p/13793233.html