prefetches

Url is used to set a list of all the pre-requisites, the portion URL, and automatically initiates a request (better developer code loading) after entering the applet. When a developer can initiate a request request again increased cache parameters, if the prefetch request configuration has been returned, it will directly return from a request, if the prefetch request configuration has not been returned, the times when the request will not send the request to complete before continuing request .

Example:

// app.json
{
prefetches: [
'https://m.baidu.com'
]
}

 

swan.request ({ 
URL: 'https://m.baidu.com',
usePrefetchCache: to true,
Success: function ( RES) { the console.log ( 'cache results:', RES); } });



Note: The
configuration items can increase the variable, and this variable can only come from the transfer agreement to open a small program in the query. Such as:

// app.json
{
prefetches: [
'https://m.baidu.com'
]
}

 

Open the applet in the agreement, but also need to carry this argument:

pages/index/index?id=123

 

Thus, when the initiation request using the request again, the prefetches can use configuration.

Guess you like

Origin www.cnblogs.com/furuihua/p/11430920.html