Vue对Html标签应用条件渲染

我的需求

在flag属性为true时 渲染标签的html为

<input :data-val-required="不能为空"/>

在flag属性为false时 渲染标签的html为

<input />

代码实现

<input :data-val-required="flag?'不能为空':null"/>
原文地址:https://www.cnblogs.com/xiaoti/p/10572092.html