将其放在构造函数中:
if (window.performance) { if (performance.navigation.type == 1) { alert( "This page is reloaded" ); } else { alert( "This page is not reloaded"); }}它将起作用,请在stackblitz上查看此示例。

将其放在构造函数中:
if (window.performance) { if (performance.navigation.type == 1) { alert( "This page is reloaded" ); } else { alert( "This page is not reloaded"); }}它将起作用,请在stackblitz上查看此示例。