The method of layer as a blocking popup layer

 

I encountered a problem today: the source address of the article https://www.yii666.com/article/301050.html?action=onAll

  The layer pops up a confirm prompt window, and the follow-up code has been executed before confirming the corresponding button. The judgment I made here is whether to perform follow-up operations, but because of the non-blocking characteristics of layer.confitm This caused my control to fail, and I couldn't achieve the effect of clicking OK or canceling.

I have studied several methods, but they are not very good. Some methods put all the subsequent operations in the callback function, but this operation affects my current logic, and it is not friendly to the encapsulation of the method, so I discarded it. Article source address https://www.yii666.com/article/301050.html?action=onAll

  Later, I Googled a method to achieve blocking pop-up windows through the async keyword: directly the source address of the above article: https://www.yii666.com/article/301050.html?action=onAll

First write the keyword async at the beginning of the method you need to block,

 

Here is a click event, so add the async keyword directly to the function.

Then the await keyword needs to be added in front of the method that needs to be blocked internally, as shown in the figure: Article source address: https://www.yii666.com/article/301050.html?action=onAll

In this way, the code can stop at this method. It should be noted that the MrIsLocked() method here also needs to add the async keyword when writing the specific logic of the method. https://www.yii666.com/

That is, when the method is declared, as shown in the figure:

  To put it simply, add the async keyword to the method declaration of the pop-up window, and add the await keyword when calling the method to achieve this effect.

Guess you like

Origin blog.csdn.net/ok060/article/details/131518036