There is a function to trigger the script when a screen opens and ends in the requirement
It is easier to open the screen, just ngOnInit directly, after obtaining the script configuration of the screen, you can directly call the script to execute it.
I thought about the trigger of the screen exit, and it is divided into 2 situations:
1. Exit the preview screen: This is based on the preview screen in the editor. The main project is still there when you exit, so you can hear it directly with ngOnDestroy
2. Directly close the browser tab page: This is a bit troublesome, angular can’t monitor directly, you need to monitor the window.onbeforeunload method, which I wrote here in ngAfterViewInit
The result is obvious, the tab page is closed without even sending the request.
At present, I think of delaying to make a request to execute script data (the result is not important), just make a request
At this time, you can see that after the delay is over, the request has been sent
Read More:
- “Failed to load resource: net::ERR_FILE_NOT_FOUND” error. The project created by vue-cli 3.0 can run under dev, and an error is reported after packaging, and the page is blank.
- Vue a page is mounted to send multiple requests at the same time, and the loading is processed uniformly
- [Solved] Angular basic create component error: Is it missing an @NgModule annotation
- JS getting ${pageContext.request.contextPath} Get the root path of the project
- [Solved] Vue Project Modify Page Error: CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory
- If the request parameter is formdata, use the Ajax operation
- How to open a page in a new window by Vue router
- [Solved] Angular&CI/CD:Error: initial exceeded maximum budget
- NPM publish an angular library Error [How to Solve]
- Difference between contenttype and datatype in Ajax request of jquery
- Vue refreshes the current page (no flash screen will appear)
- Solve the asynchronous execution of callback function in Axios request processing interceptor
- Vue Project Error: Proxy error: Could not proxy request [How to Solve]
- Interface request error 504 gateway time out [How to Solve]
- React project is packaged and set as required Error [How to Solve]
- [Solved] electron-vue project error: Object.fromEntries is not a function electron-vue
- How to Fix “HTTP 405 method not allowed” Error
- How to React page to achieve entry and exit animation
- H5 page left and right stretch content area
- Solution to build error in Vue project (error in static/JS)/vendor.xxxxx.js from UglifyJs)