antdesignvue中使用VNode写法

1、使用场景
在这里插入图片描述
如图:消息提示框中,将数据中的数据单独一行显示
2、代码

 let errorList = res.result; //后端返回的数据例: ["1. 数据格式不正确","2. 数据已存在"]
    if(errorList&&errorList.length!=0){
      this.$notification.open({
        message: "数据有误!",
        duration:0,  //取消定时关闭效果
        description: h=>{
        let arr = [];
        errorList.forEach((item)=>{
          arr.push(h('p',null,item)) 
        })
        return h('div',null,arr)
       }
      })
   }

3、h函数使用(vue2x)
h(标签元素,标签属性,标签下的子元素)

一、attrs:设置html属性例如:id
1、h('div',{id:"divObj"},"hello world")
==
<div id="divObj">hello world</div>

2、h('div',null,"hello word")
==
<div>hello world</div>
3、h('div',null,[h('span',null,'1.张三'),h('span',null,'2.李四')]
==
<div>
	<span>1.张三</span>
	<span>2.李四</span>
</div>

二、props:设置DOM节点例如value
1、h('input',{type:"text",value:"hello"},null)
==
<input type="text" value="hello"/>

三、classDOM类名
1、h('div',{class:'iconCss'},'hello')
==
<div class="iconCss">hello</div>

四、style
1、h('div',{style:'color:red'},'hello')
==
<div style="color:red">hello</div>
  • 9
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值