DefaultWebPage.ets 730 Bytes
import router from '@ohos.router';
import { Action } from 'wdBean';
import { Logger } from 'wdKit';
import { WdWebComponent } from 'wdWebComponent';

const TAG = 'DefaultWebPage';

@Entry
@Component
struct DefaultWebPage {
  private url?: string;
  @State reload: number = 0;

  aboutToAppear() {
    let action: Action = router.getParams() as Action
    if (action) {
      this.url = action.params?.url
    }
  }

  onPageShow() {
    Logger.info(TAG, `DefaultWebPage# onPageShow:::refresh`);
    this.reload = ++this.reload
  }

  onPageHide() {
    this.reload = 0
  }

  build() {
    Column() {
      WdWebComponent({
        webUrl: this.url,
        backVisibility: false,
        reload: this.reload
      })
    }
  }
}