【vue开发】render的用法,全局引入/组件简化代码
在main.ts 中添加
Vue.component('sayHello',{ render(h){ return h('p',{ style:{ color:'red' } },`早上好`)//格式是`${this.userName}` }, data(){ return{ userName:'小明' } } })
注意参数说明:h(标签,属性,值)
在各组件中使用
<sayHello></sayHello>
本文来自博客园,作者:JeckHui;
个人主页:前端实用站点推荐; 热榜资讯早读:热榜资讯-导航;
转载请注明原文链接:https://www.cnblogs.com/xiaohuizhang/p/13793233.html