【发布时间】:2018-03-28 10:09:54
【问题描述】:
大家好,可以为 axios 成功赋值,这样我就可以将该变量用于其他函数,例如:-
<script>
var x ="";
export default {
methods:{
getshop(){
this.$http.get('http://localhost:3000/api/shopestablishments') .then(function (response) {
return x= response.data;//how i can assign value of x from here
})
},
onClick(){
// how I can use assign variables of x over here
},
},
}
</script>
我搜索了很多,很困惑我怎么能做这件事
【问题讨论】:
-
你的代码看起来很奇怪,因为你在同一个函数中有 2 个
returns。
标签: javascript ajax laravel vue.js axios