表單組件
1栋豫、picker 選擇器組件
range:指定一個數(shù)組(指定一份展示的數(shù)據(jù))挎峦。
range-key:如果range數(shù)組是一個對象數(shù)組阻逮,需要添加range-key屬性傍念,指定選擇器中顯示的內(nèi)容(從對象身上指定一個屬性)歪架。
bindchange:value 改變時觸發(fā) change 事件股冗,event.detail = {value}。
<picker?class="txt"?bindchange="bindPickerChange"?range-key="Name"?range="{{sections}}">
?????<view>
????????<!--?根據(jù)選擇器選中的索引和蚪,顯示對應(yīng)的名稱?-->
????????{{sections[sectionsActiveIndex].Name}}
?????</view>
??</picker>
通過e.detail.value獲取當(dāng)前列表value的索引止状。
???bindPickerChange:?function(e)?{
console.log(e.detail.value) ?//獲取下標(biāo)
???}
2烹棉、input 輸入框
placeholder:輸入框為空時占位符。
<input?value=""?placeholder="請輸入搜索關(guān)鍵字"?/>
3怯疤、textarea 多行文本框
maxlength:最大輸入長度浆洗。設(shè)置為 -1 的時候不限制最大長度。
<textarea?maxlength="-1"?value=""?/>
JS數(shù)據(jù)更新方法
(1)直接賦值
該方法只更新js中的數(shù)據(jù)集峦,不會重新渲染到頁面伏社。
???this.data.section_id?=?this.data.sections[index].Id
(2)setData()方法
該方法更新數(shù)據(jù)后,重新渲染頁面塔淤。
???this.setData({
???????activeIndex:?index
???})