material-hmos/entry/src/main/ets/pages/web/WebPage.ets

35 lines
889 B
Plaintext

import { webview } from '@kit.ArkWeb';
import { TitleBar } from '../../view/TitleBar';
import { window } from '@kit.ArkUI';
@Entry
@ComponentV2
struct WebPage {
windowStage: window.WindowStage = AppStorage.get("windowStage") as window.WindowStage;
controller: webview.WebviewController = new webview.WebviewController();
@Local title: string = '';
@Local url: string = '';
aboutToAppear(): void {
this.initParams();
}
initParams() {
const params = this.getUIContext().getRouter().getParams() as Record<string, Object>;
if (params) {
this.title = params.title as string;
this.url = params.url as string;
}
}
build() {
Column() {
TitleBar({ title: this.title, isDark: false }).width('100%')
Web({ src: this.url, controller: this.controller }).width('100%').layoutWeight(1)
}
.width('100%')
.height('100%')
}
}