surroundings
- IU: Staying weapp
- Applets
- mpvue
Problem Description
vant-weapp
There is a component ActionSheet 上拉菜单
, you need to use their select
method to get users have to click on the selected value, the value of his event.detail
, I need to get this value
UI effects
html
<!-- 性别弹窗 -->
<van-action-sheet :show="sex.show" :actions="sex.actions" :cancel-text="sex.cancel" @cancel='myCancel("sex")' @select="sexSelect" />
Note that@select="sexSelect"
Configuration
sex: {
show: false,
cancel: '取消',
current: '',
actions: [
{
name: '男'
},
{
name: '女'
}
]
}
function
// 性别弹窗里面
sexSelect: function (e) {
console.log(e)
this.sex.show = false
this.sex.current = e.mp.detail.name
},
e.mp.detail.name
Users will be able to get a drop-down selection Found
Improved demand
I do not just want to get user input, I would like to carry other parameters, fill the pit for a long time, only to have to find a method, pay attention to this @select="sexSelect($event,'name')"
side too $event
, there must be $
, otherwise not get, error
<!-- 性别弹窗 -->
<van-action-sheet :show="sex.show" :actions="sex.actions" :cancel-text="sex.cancel" @cancel='myCancel("sex")' @select="sexSelect($event,'name')" />
js
// 性别弹窗里面
sexSelect: function (e, name) {
console.log(e)
console.log(name)
this.sex.show = false
this.sex.current = e.mp.detail.name
},
So I can get the user to select the parameter name and value have to carry
The above parameters have to carry another implementation
<!-- 性别弹窗 -->
<van-action-sheet data-index="250" :show="sex.show" :actions="sex.actions" :cancel-text="sex.cancel" @cancel='myCancel("sex")' @select="sexSelect" />
Note: data-index="250"
If the binding was a property name, and needs :
, for example :data-index="myValue"
, index
can be changed to another name