代码如下:
<template>
<view class="content">
<view class="bg lists">
<view class="user_center">
<view class="uni-list-cell">
<view class="uni-list-cell-left">
请选择国家
</view>
<view class="uni-list-cell-db">
<picker @change="pickerChange($event)" :value="index" :range="dataList">
<view class="uni-input">{{dataList[index]}}</view>
</picker>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
index:0,
dataList: ['中国','美国','英国','德国'], //这里保存值
dataIDList:[5,7,9,10], //这里是每个值对应的id
}
},
onLoad:function(options) {
},
methods: {
pickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.target.value+"===="+this.dataList[e.target.value] + this.dataIDList[e.target.value]);
this.index = e.target.value;
}
}
}
</script>
原创文章,来源www.aspbc.com,转载请注明来源,谢谢