**注意:**点击选项关闭下拉框,@click.stop="selectOption(item),使用.stop阻止冒泡
<view class="info_input_text" @tap="select">
{{currentOption}} //当前选项
<view class="select_box" v-show="unfold" >
<view class="select_option"
:style="{background: currentOption == item ? '#F5F5F5' : '#fff'}"
v-for="(item, index) in array"
:key="index"
@click.stop="selectOption(item)">
{{item}}</view>
</view>
</view>
<script>
export default {
data(){
return {
unfold: false,
currentOption: '滴滴',
array: ['滴滴', '哈啰', '曹操', '神州'],
}
},
methods: {
//平台选择
select() {
let vm = this;
vm.unfold = !vm.unfold;
},
selectOption(e) {
console.log(e)
let vm = this;
vm.unfold = false;
vm.currentOption = e;
},
}
}
</script>