我想强制我的现代页面每 3000 秒刷新一次 >> 所以我开发了一个 spfx 扩展 >> 在我的 .ts 中我添加了以下代码:-
export default class HelloWorldApplicationCustomizer
extends BaseApplicationCustomizer<IHelloWorldApplicationCustomizerProperties> {
@override
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);
const cssUrl: string = this.properties.cssurl;
const scriptUrl: string = this.properties.scripturl;
if (cssUrl) {
// inject the style sheet
const head: any = document.getElementsByTagName("head")[0] || document.documentElement;
let customStyle: HTMLLinkElement = document.createElement("link");
customStyle.href = cssUrl;
customStyle.rel = "stylesheet";
customStyle.type = "text/css";
const head2: any = document.getElementsByTagName("head")[0] || document.documentElement;
let customScript: HTMLLinkElement = document.createElement("link");
customScript.href = scriptUrl;
customScript.rel = "script";
customScript.type = "text/javascript";
head.insertAdjacentElement("beforeEnd", customStyle);
head2.insertAdjacentElement("beforeEnd", '<META HTTP-EQUIV="refresh" CONTENT="3000">');
}
return Promise.resolve();
}
现在,当我将 SPFX 添加到我的网站时,页面不会每 3000 秒加载一次。所以似乎head2.insertAdjacentElement("beforeEnd", '<META HTTP-EQUIV="refresh" CONTENT="3000">');
没有任何效果。虽然我有一个正确应用的 customStyle 。有什么建议吗?