最近用开发了一款小程序,用到的vant组件,是mvue框架,以后改框架,感觉mpvue框架好多限制
直接上代码吧,目的是为了方便自己
html代码
<van-field v-model.trim="recordList.purposeName" required label="停车场用途:" placeholder="请选择车场用途" readonly is-link="true" @click="selectPurpose"/>
<van-action-sheet
title="请选择车场用途"
:show="showPurpose"
:actions="purposeList"
@close="showPurpose = false"
@select="onSelectPurpose"
/>
js代码两个方法
//选择车场用途
selectPurpose(){
this.showPurpose = true;
},
onSelectPurpose(e){
this.showPurpose = false;
this.recordList.purposeName = e.mp.detail.name;
this.recordList.purpose = e.mp.detail.id;
},
别忘了data里定义的showPurpose和purposeName ,purpose 这些字段