解决方法:在使用axios之前,把this关键字赋值给某变量,在使用axios时,使用该变量
let self=this;
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
list:[]
},
methods:{
async getCustomer(){
let self=this;
await axios.get("http://localhost/customerController").then(function (ret){
self.list=ret.data;
}).catch(function (ret) {
console.log("error")
});
}
},
mounted() {
this.getCustomer()
}
})
</script>