修改下拉框展示默认值问题 #9

Merged
zhangqi merged 1 commits from zq-popup into master 3 weeks ago
  1. 25
      src/components/GuipSelect.vue

25
src/components/GuipSelect.vue

@ -1,21 +1,12 @@
<template> <template>
<el-form-item <el-form-item :style="{ ...style, height: height, ...styleObject }"
:style="{...style,height:height,...styleObject}" :class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']" :label="label"
:class="[{'column':column},{'w510':addClass=='w510'},{'w388':addClass=='w388'},'form-item']" :prop="prop" :rules="rules">
:label="label" :prop="prop" :rules="rules">
<p v-if="desc" class="desc_right">{{ desc }}</p> <p v-if="desc" class="desc_right">{{ desc }}</p>
<el-select <el-select :style="{ width: width }" :placeholder="placeholder1" @change="handleChange" v-model="selectedValue">
:style="{width:width}" <el-option v-for="item in options" :key="item.value" :label="item.label" :disabled="item.disabled"
:placeholder="placeholder1"
@change="handleChange"
v-model="selectedValue">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:disabled="item.disabled"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
@ -37,6 +28,9 @@
watch: { watch: {
value(newVal) { value(newVal) {
this.selectedValue = newVal; this.selectedValue = newVal;
},
defaultValue(newVal) {
this.selectedValue = newVal;
} }
}, },
mounted() { mounted() {
@ -44,6 +38,9 @@
if (this.defaultValue != null) { if (this.defaultValue != null) {
this.selectedValue = this.defaultValue; this.selectedValue = this.defaultValue;
} }
if (this.value != null) {
this.selectedValue = this.value;
}
// //
if (this.placeholder) { if (this.placeholder) {
this.placeholder1 = this.placeholder; this.placeholder1 = this.placeholder;

Loading…
Cancel
Save