简体   繁体   English

如何知道浏览器页面是否正在Vue.js项目中加载?

[英]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? 如何知道浏览器页面是否正在Vue.js项目中加载?

在此处输入图片说明

in browser, such as in Chrome, if we open a page, if the networking is not finish, there will have a circle animation. 在浏览器中(例如在Chrome中),如果我们打开一个页面,如果联网尚未完成,则会出现一个圆形动画。

but in our development, how can we get this status? 但是在我们的发展中,我们如何获得这种地位?

You can do this using simple Javascript 您可以使用简单的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 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 . 有关更多详细信息,请访问W3Schools-document.readystate

Hope this solves your query. 希望这可以解决您的查询。

I think what you are searching for is the javascript/HTML onLoad() event. 我认为您要搜索的是javascript / HTML onLoad()事件。 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. 当页面被加载时调用它,作为HTML标签,您可以添加一个函数调用,该函数调用将在页面加载后执行,Java脚本也是如此,您可以在其中创建eventListener来在同一事件之后调用函数。

Here is an helpfull link: OnLoad W3School 这是一个有用的链接: OnLoad W3School

Window.onload() method detect when a page is loaded. Window.onload()方法检测何时加载页面。 may this can be helpful 这可能会有所帮助

How do I detect when a web page is loaded? 如何检测何时加载网页?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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