支付寶小程序input 動態改內容不生效問題

代碼:

axml代碼如下

<input type="text" onInput='bindInput' name="firstname" value="{{firstname}}" maxlength='16' placeholder-style='color:#c5c5c5' placeholder='如:SAN'></input>

js代碼如下

bindInput: function (e) {
	info= e.detail.value.trim().replace(/[^a-zA-Z]/g, "").toUpperCase();
	this.setData({ firstname:info });
    },

運行結果:

不生效,input的值不受控制,後臺在官方文檔找到controlled這個屬性,記錄一下

<input controlled="true" type="text" onInput='bindInput' name="firstname" value="{{firstname}}" maxlength='16' placeholder-style='color:#c5c5c5' placeholder='如:SAN'></input>

解決方法:

在這裏插入圖片描述

文檔地址:https://docs.alipay.com/mini/component/input

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章