<u-form-item prop="area" :border-bottom="false">
<view class="taskName2" @click="change" style="color: #808080;">
<text>*</text>
<text :class="!!form.area ? 'select' : ''">
{{ !!form.area ? form.area : '请选择所在地区' }}
</text>
</view>
<u-picker
class="region"
mode="region"
v-model="show"
@confirm="confirm"
@cancel="cancel"
:area-code="arr"
:mask-close-able="false"
></u-picker>
</u-form-item>
<button type="primary" plain="true" @click="reset">重置</button>
data() {
return {
form: {
area: ''
},
arr: [],
show: false
};
},
methods: {
cancel(e) {
},
change() {
this.show = true;
},
confirm(e) {
// 省市区拼接
this.form.area = e.province.label + '-' + e.city.label + '-' + e.area.label;
this.arr[0] = e.province.value;
this.arr[1] = e.city.value;
this.arr[2] = e.area.value;
},
reset() {
this.form.area = '';
this.arr = [];
}
}
<style lang="less" scoped>
button {
width: 100px;
}
.select {
color: #000;
}
.taskName2 {
position: relative;
border: 1px solid #ccc;
width: 80%;
margin: 0 auto;
padding: 0 10px;
}
.taskName2::after {
position: absolute;
top: 24rpx;
right: 24rpx;
content: '';
width: 12rpx;
height: 12rpx;
border-right: 4rpx solid #000;
border-bottom: 4rpx solid #000;
transform: rotate(45deg);
/* 添加过渡 */
transition: all 0.4s;
}
.taskName2:hover::after {
transform: rotate(225deg);
}
效果图如下