Vue + element realizes dynamic display of background data to options


Realize the dynamic display of the option value options data in the [selector selector] , instead of hard-coded data, my role ID data is as follows:
Now realize the request to display these data on the option

The implementation is as follows:

[Use the selector selector] in element-ui :

          v-for="item in roleList"

Customize an empty array in data:
write a request to implement data in methods:

getroleList() {
   getRoleList( this .name).then( res => {
      let result =;
      console .log( "Role get list: " + JSON .stringify( this .roleList));
     result.forEach(element => {
     }).catch( error => {

The created implementation shows:
where getRoleList is my encapsulated get request:

The result is as follows:

Leave a Comment

Your email address will not be published. Required fields are marked *