this.options[0] ? this.options[0].label : null
<script>
export default {
// props: ['title', 'selectShow', 'options'],
// 改成这个形式
props: {
options: {
type: Array,
default: () => []
},
title: {
type: String,
default: ''
},
selectShow: {
type: Boolean,
default: false
}
},
data() {
return {
sValue: ''
}
},
mounted() {
// console.log(this.options);
// 判断有数据赋值
this.sValue = this.options[0] ? this.options[0].label : null
},
methods: {
change(e) {
console.log(e, 'e');
this.$emit("sValue", this.sValue, this.options[0].label)
}
}
}
</script>