javascript - How to make ElementUI Select component selected by default?
高洛峰
高洛峰 2017-06-26 10:52:36
0
4
927

How to select the ElementUI Select component by default?

The data in these options are dynamically captured, but now I need to set one of the options to the default value.
If the current page is edited by the user, after I obtain the user's parameters through ajax, how do I set the user's parameters as default in the options?

Attached js code:

<script>
    export default {
        name: 'edit',
        created (){

            this.$http.get('xxxxxx/api/getUserAttributes').then( resolve => {
                this.departments = resolve.data.departments
                this.userlevels = resolve.data.userlevels
                this.positions = resolve.data.positions
            }, reject => {
                this.$message.error('error')
            })

            let query_id = this.$route.query.id ? this.$route.query.id : 30

            this.$http.get('xxxxxx/api/getUser', {
                params: {
                    query_id: query_id
                }
            }).then( resolve => {
                this.form.id = resolve.data[0].id
                this.form.account = resolve.data[0].account
                this.form.password = resolve.data[0].password
                this.form.nickname = resolve.data[0].nickname
                this.form.email = resolve.data[0].email
            }, reject => {
                this.$message.error('error')
            })


        },
        data (){
            return {
                form: {
                    id: '',
                    account: '',
                    nickname: '',
                    password: '',
                    email: '',
                    sex: 1,
                    authority: []
                },
                departments: [],
                userlevels: [],
                positions: []
            }
        }
    }
</script>
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
小葫芦

Make the value of v-model correspond to the value in the checkbox to display

学霸

As shown in the picture, which value the v-model is set to equals is the actual label

扔个三星炸死你

I didn’t see your html, but the value bound to v-model is the same as the value of your option. I can't see the binding value of v-model in your html either.

代言

Changed the demo in the official document
https://jsfiddle.net/athena03...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!