style="font-size: 180rpx;"
curFontSize
,默认值为 "180rpx"
, 并且替换掉了原来的 style="font-size: 180rpx;"
curFontSize: "180rpx",
:style="{fontSize: curFontSize}"
curFontSize
的值showValue
的变化,然后在回调函数中动态计算 curFontSize
的值watch: {
showValue(newVal, oldVal) {
newVal += "";
switch (newVal.length) {
case 8:
this.curFontSize = "160rpx";
break;
case 9:
this.curFontSize = "150rpx";
break;
case 10:
this.curFontSize = "130rpx";
break;
case 11:
this.curFontSize = "120rpx";
break;
default:
this.curFontSize = "180rpx";
break;
}
}
},
curFontSize
的值运行效果如下: