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

CodePudding user response:

reference past deep young blue reply: 3/f
you write in the methods of search function didn't call? to inside the created this. The search () call

Call, no call is no reaction, it is an error, the backend is django API

Traceback (the most recent call last) :
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ wsgiref \ handlers py", line 138, in the run
Self. Finish_response ()
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ wsgiref \ handlers py", line 180, in finish_response
The self. The write (data)
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ wsgiref \ handlers py", line 274, in the write
Self. Send_headers ()
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ wsgiref \ handlers py", line 332, in send_headers
Self. Send_preamble ()
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ wsgiref \ handlers py", line 255, in send_preamble
(' Date: % s \ r \ n '% format_date_time (time. Time ())). The encode (' iso - 8859-1)
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ wsgiref \ handlers py", line 453, in _write
Result=self. Stdout. Write (data)
File "C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ lib \ socketserver py", line 796, in the write
Self. _sock. Sendall (b)
ConnectionAbortedError: [10053] WinError software in your host suspended a connection has been established,

CodePudding user response:

Your alert on the outside then, axios the request is asynchronous, only to get in then
  • Related