简体   繁体   中英

How to know the browser page whether is loading in Vue.js project?

How to know the browser page whether is loading in Vue.js project?

在此处输入图片说明

in browser, such as in Chrome, if we open a page, if the networking is not finish, there will have a circle animation.

but in our development, how can we get this status?

You can do this using simple Javascript

if (document.readyState == "completed") {
    alert("Your page is loaded");
}

Return Value : A String, representing the status of the current document.

One of five values:

  • uninitialized - Has not started loading yet
  • loading - Is loading
  • loaded - Has been loaded
  • interactive - Has loaded enough and the user can interact with it
  • complete - Fully loaded

For more details visit W3Schools - document.readystate .

Hope this solves your query.

I think what you are searching for is the javascript/HTML onLoad() event. It's called when a page has been loaded, as an HTML tag you can add a function call which will be executed once the page is loaded and same goes for Javascript where you can create an eventListener to call a function following the same event.

Here is an helpfull link: OnLoad W3School

Window.onload() method detect when a page is loaded. may this can be helpful

How do I detect when a web page is loaded?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM