<template>
    <div style="display:inline-block">
        <el-select :value="district" style="width:100%" placeholder="请选择区县" clearable>
            <el-option v-for="item in districts" :key="item.id" :value="item.name" :label="item.name"></el-option>
        </el-select>
    </div>
</template>
<script>
export default {
    props: {
        value: {
            type: String
        }
    },
    data() {
        return {
            districts: [],
            district: ''
        };
    },
    created() {
        this.$http
            .post('/setting/byFlag', { flag: 2 })
            .then(res => {
                this.districts = res;
            })
            .catch(e => {
                console.log(e);
                this.$message.error(e.error);
            });
    },
    watch: {
        value() {
            this.district = value;
            console.log(this.value);
        }
    }
};
</script>
