第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

angular 中 performance.navigation.type 的替代品是什么?

angular 中 performance.navigation.type 的替代品是什么?

慕哥6287543 2021-12-12 15:30:33
我有這個代碼是為了知道頁面是否被用戶重新加載,不幸的是已被棄用。我想知道 angular 是否有這種方法。if (performance.navigation.type === 1) {   console.log('is refreshed')}if (performance.navigation.type === 0) {   console.log('the user is arrived')}  
查看完整描述

3 回答

?
HUH函數(shù)

TA貢獻(xiàn)1836條經(jīng)驗 獲得超4個贊

不是 Angular 特有的,但是這個 API 已經(jīng)被PerformanceNavigationTiming取代,它也有一個type屬性,但它返回一個字符串而不是數(shù)字代碼。


但是我只是注意到 Chrome 不會為 iframe 公開它,它總是會輸出"navigate".


以下代碼段在 Chrome 中不起作用,請在外部視圖中嘗試使用此 plnkr。


const entries = performance.getEntriesByType("navigation");


console.log( entries.map( nav => nav.type ) );


rel.onclick = e => location.reload();

<button type="button" id="rel">reload</button>

<a href="404">go to 404 (come back with your browser's back button)</a>


查看完整回答
反對 回復(fù) 2021-12-12
?
開滿天機(jī)

TA貢獻(xiàn)1786條經(jīng)驗 獲得超13個贊

performance.navigation已棄用。要獲取導(dǎo)航類型,您可以使用getEntriesByType


例子


console.log(performance.getEntriesByType("navigation")[0].type)

該type值可以是


enum NavigationType {

    "navigate",

    "reload",

    "back_forward",

    "prerender"

};

查看更多:https : //w3c.github.io/navigation-timing/#sec-performance-navigation-types


查看完整回答
反對 回復(fù) 2021-12-12
?
MYYA

TA貢獻(xiàn)1868條經(jīng)驗 獲得超4個贊

我想添加運行:

performance.getEntriesByType("navigation");

在 Safari 中返回一個空數(shù)組


查看完整回答
反對 回復(fù) 2021-12-12
  • 3 回答
  • 0 關(guān)注
  • 1730 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號