3

I am working on a Vue app made with element UI and I have a bunch of el-select whose el-options need to have default values, meaning the form select fields already have one option pre-selected (of course the user can still choose other options). I cannot find any attribute in the official doc https://element.eleme.io/#/en-US/component/select#select But there should be a way to achieve this right?

This is my code

<el-form-item label="some label" prop="someprop">
    <el-select v-model="form.status" filterable clearable>
        <el-option
            v-for="(item, index) in config.status"
            :key="index"
            :label="item"
            :value="index"
            how to have default option here??
            >
        </el-option>
    </el-select>
</el-form-item>
3

1 Answer 1

1

Just put in the form.status the indexes that should be pre-selected. Vue will take care of the rest.

data(){
   return {
      form: { status: ['thisWillBePreSelected'], },
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.