fix: update selectors

This commit is contained in:
Qiuxia Fan 2021-12-27 15:57:01 +08:00
parent 227ef4f092
commit fe81197d49
3 changed files with 15 additions and 12 deletions

View File

@ -44,10 +44,11 @@ const props = defineProps({
type: Array as PropType<Option[]>, type: Array as PropType<Option[]>,
default: () => [], default: () => [],
}, },
value: { type: String, default: "" },
size: { type: String, default: "small" }, size: { type: String, default: "small" },
placeholder: { type: String, default: "Select a option" }, placeholder: { type: String, default: "Select a option" },
}); });
const selected = ref<string>(""); const selected = ref<string>(props.value);
function changeSelected() { function changeSelected() {
const optionSele = props.options.filter( const optionSele = props.options.filter(
(d: Option) => d.value === selected.value (d: Option) => d.value === selected.value

View File

@ -26,6 +26,7 @@ limitations under the License. -->
<div class="item"> <div class="item">
<div class="label">{{ t("layer") }}</div> <div class="label">{{ t("layer") }}</div>
<Selector <Selector
:value="states.layer"
:options="Options" :options="Options"
size="small" size="small"
placeholder="Select a layer" placeholder="Select a layer"
@ -36,6 +37,7 @@ limitations under the License. -->
<div class="item"> <div class="item">
<div class="label">{{ t("entityType") }}</div> <div class="label">{{ t("entityType") }}</div>
<Selector <Selector
:value="states.entity"
:options="EntityType" :options="EntityType"
size="small" size="small"
placeholder="Select a entity" placeholder="Select a entity"
@ -63,7 +65,7 @@ const { t } = useI18n();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const states = reactive({ const states = reactive({
name: "", name: "",
layer: "", layer: Options[0].value,
entity: EntityType[0].value, entity: EntityType[0].value,
}); });
const onCreate = () => { const onCreate = () => {

View File

@ -33,23 +33,23 @@ export const EntityType = [
]; ];
export const Options = [ export const Options = [
{ {
value: "Option1", value: "layer1",
label: "Option1", label: "layer1",
}, },
{ {
value: "Option2", value: "layer2",
label: "Option2", label: "layer2",
}, },
{ {
value: "Option3", value: "layer3",
label: "Option3", label: "layer3",
}, },
{ {
value: "Option4", value: "layer4",
label: "Option4", label: "layer4",
}, },
{ {
value: "Option5", value: "layer5",
label: "Option5", label: "layer5",
}, },
]; ];