51 lines
975 B
Vue
51 lines
975 B
Vue
|
<template>
|
||
|
<el-select v-model="val" @change="change">
|
||
|
<el-option v-for="item in options" :key="`land_type_${item.value}`" :value="item.value" :label="item.label" placeholder="请选择">
|
||
|
{{ item.label }}
|
||
|
</el-option>
|
||
|
</el-select>
|
||
|
</template>
|
||
|
|
||
|
<script setup>
|
||
|
import { ref, watch } from 'vue';
|
||
|
|
||
|
const props = defineProps({
|
||
|
// 父组件传过来的值
|
||
|
value: {
|
||
|
type: String || null,
|
||
|
default: null,
|
||
|
},
|
||
|
});
|
||
|
const emit = defineEmits(['update:value']);
|
||
|
/* --------------- data --------------- */
|
||
|
// #region
|
||
|
|
||
|
const val = ref(null);
|
||
|
watch(
|
||
|
() => props.value,
|
||
|
() => {
|
||
|
val.value = props.value;
|
||
|
},
|
||
|
{
|
||
|
deep: true,
|
||
|
immediate: true,
|
||
|
}
|
||
|
);
|
||
|
const options = ref([
|
||
|
{ label: '是', value: '0' },
|
||
|
{ label: '否', value: '1' },
|
||
|
]);
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
/* --------------- methods --------------- */
|
||
|
// #region
|
||
|
function change(val_) {
|
||
|
val.value = val_;
|
||
|
emit('update:value', val_);
|
||
|
}
|
||
|
// #endregion
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped></style>
|