<div class="textcontain"> <input type="text" v-model.number="item.cardComboMoney" maxlength="5" placeholder="设定数值" oninput="value=value.replace(/^(0+)|[^\d]+/g,'')" :disabled='disabled' :style="{width:text(item.cardComboMoney)}" > <span class="textshow" v-if="item.cardComboMoney!=0&&item.cardComboMoney!=''" >元</span> </div>
computed: { text () { return function (value) { if (value == '' || value == 0) { return '100%' } else { return String(value).length * 0.32 + 'rem' //可以根据自己的需要修改单位或计算方式 } } } },
标签:Vue,return,value,宽度,长度,input From: https://www.cnblogs.com/zhangzhijian/p/16856073.html