用vue给下拉列表添加动态值

用axios从后台获取数据

 data(){
        return{
            name:'评论管理',
            comments:[],
            comment:{},
            centerDialogVisible: false ,
            form:{},
            list:[]    //定义数组,存放从后台获取的数值
                     
        }
    },
    created(){        
        this.reloadData();
        this.getUrl();   //调用
    },
    
    methods:{
        getUrl(){
            axios.get('/order/findAll')
            .then((response)=>{
                console.log('get请求成功:',response.data.data);               
                //将对象转换为数组
                for(let i in response.data.data){                
                   this.list.push(response.data.data[i]);      //this指向vue实例          
                }
                 console.log('list数组',this.list);
            })
        }
    }

将获取的值在下拉框中遍历

 
    
         
     
  

你可能感兴趣的:(Vue)