当前位置:网站首页>Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
2022-06-25 12:30:00 【Chafferer WANG】
The idea is to use vue Of watch The listener :
After the network request is completed , change watch Listen for the value , Let it trigger subsequent actions .
Here is the sample code :
export default {
data(){
return {
isInit: 0 // Custom variable , It is used to trigger the operation after the network request
}
},
watch: {
// Listen for custom variables , When the duty becomes 1 when ( After the network request is completed ), Follow up .
// Among them, formal parameters newVal On behalf of the variable isInit Changed value ,oldVal On behalf of the variable isInit The value before the change
isInit: function(newVal, oldVal) {
if(newVal == 1) {
// The operation method after the network request is completed
this.afterInit()
}
}
},
onShow() {
// Network request method executed
this.networkRequest()
},
methods: {
networkRequest() {
// Make a network request here
....
// After the request is completed, the custom variable isInit Change it to 1, The listener is triggered watch Medium isInit Method
this.isInit = 1
},
afterInit() {
// Here is to wait for the completion of the network request before executing the subsequent code
}
}
}
边栏推荐
- R language uses ordinal or. The display function obtains the summary statistical information of the ordered logistic regression model (the odds ratio and its confidence interval corresponding to the v
- R语言dplyr包summarise_at函数计算dataframe数据中多个数据列(通过向量指定)的计数个数、均值和中位数、在每个函数内部指定na.rm参数、通过list指定函数列表
- R language dplyr package filter function filters the data rows in the specified list whose contents in the dataframe data are not (not equal to one of the specified vectors)
- 19、wpf之事件转命令实现MVVM架构
- A commonly used statistical modeling method -- difference analysis
- Install MySQL client
- New and old cluster migration of Minio data
- R语言dist函数计算dataframe数据中两两样本之间的距离返回样本间距离矩阵,通过method参数指定距离计算的方法、例如欧几里得距离
- How to use SPSS to do grey correlation analysis? Quick grasp of hand-to-hand Teaching
- Mysql database logs binlog save aging (expire\u logs\u days)
猜你喜欢

Why do we do autocorrelation analysis? Explain application scenarios and specific operations

Today, I will explain to you what is DFI and its development prospects

Why can't you Ping the website but you can access it?

A set of automated paperless office system (oa+ approval process) source code: with data dictionary

How to use SPSS to do grey correlation analysis? Quick grasp of hand-to-hand Teaching

plt. GCA () picture frame and label

Full nanny tutorial of Market Research Competition (experience sharing)

How do super rookies get started with data analysis?

SDN system method | 9 Access network
![[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer](/img/58/d68112a3d019de66150e2f5102f436.png)
[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer
随机推荐
ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities
一套自动化无纸办公系统(OA+审批流)源码:带数据字典
Hook技术
Execution order of MySQL query statements join, on and where
20、wpf之MVVM命令绑定
R language dplyr package filter function filters the data rows in the specified list whose contents in the dataframe data are not (not equal to one of the specified vectors)
Heyangdao store management system -- share the development source code of heyangdao system
Ubuntu uninstalling PHP
JS monitors the width and height changes of div
Black Horse Chang Shopping Mall - - - 3. Gestion des produits de base
Renrenyue -- renrenyue system development source code sharing
R语言dist函数计算dataframe数据中两两样本之间的距离返回样本间距离矩阵,通过method参数指定距离计算的方法、例如欧几里得距离
Zunpin Yongyao advertising e-commerce system -- Zunpin Yongyao advertising e-commerce app system development source code sharing
plt. GCA () picture frame and label
A set of automated paperless office system (oa+ approval process) source code: with data dictionary
MySQL common interview questions
High imitation blue playing network disk file sharing to make money network disk PHP system source code
Time series analysis - how to use unit root test (ADF) correctly?
Kotlin Foundation
Development with courtesy -- share the source code of the secondary development of the app system of the imitation shopping mall