Home > front end > Online urgent, a great god, vue and axios, introduced in an HTML page, the methods can't obtain
Online urgent, a great god, vue and axios, introduced in an HTML page, the methods can't obtain
Time:10-04
In the hook, when the page loads normally return back data //mounted () { //axios. Get (' url '{params: {' s' :' s'}}) //. Then ((response)=& gt; { //this. The items=response. Data //}); ////alert (enclosing res) //} In the methods how to don't come out data, to the great spirit show Methods: { Search: the function () { Axios. Get (' url '{params: {' s' : this. Wk} a}) Then (response=& gt; {this. The items=response. Data}) The catch (error=& gt; The console. The log (error)); Alert (enclosing the items. Length); } }
CodePudding user response:
Your url is a string, refer to the https://blog.csdn.net/qq_19891827/article/details/78834183
CodePudding user response:
Introduced. In addition, it is best to axios in main js, is set to the global properties of the vue instance, vue. Prototype. $axios=axios, call in other files directly from this. $axios
CodePudding user response:
You write in the methods of search function didn't call? to inside the created this. The search () call