“53936391741dee735304e997e2289500adf970c7”上不存在“README.md”
index.uts 2.1 KB
Newer Older
1
import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView, CheckWebViewNativeView, CheckInputNativeView, CheckTextareaNativeView, CheckViewNativeView } from "../interface";
2
import { WKWebView } from 'WebKit';
3
import { UIView, UITextField, UITextView } from "UIKit"
4 5

export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
6
  const element = uni.getElementById(elementId)
7 8 9
  const view = element?.getIOSView();
  if (view != null && view instanceof WKWebView) {
    return (view! as WKWebView).canGoBack;
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
10
  }
11
  return false;
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
12 13
}

14
export const canWebViewGoForward : CanWebViewGoForward = function (elementId : string) : boolean {
15
  const element = uni.getElementById(elementId)
16 17 18 19 20
  const view = element?.getIOSView();
  if (view != null && view instanceof WKWebView) {
    return (view! as WKWebView).canGoForward;
  }
  return false;
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
21
}
22 23

export const hasNativeView : HasNativeView = function (elementId : string) : boolean {
24
  const element = uni.getElementById(elementId)
25 26 27 28 29 30
  const view = element?.getIOSView();
  if (view != null && view instanceof WKWebView) {
    return true;
  }
  return false;
}
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

export const checkWebViewNativeView : CheckWebViewNativeView = function (elementId : string) : boolean {
  return hasNativeView(elementId)
}

export const checkInputNativeView : CheckInputNativeView = function (elementId : string) : boolean {
  const element = uni.getElementById(elementId)
  const view = element?.getIOSView();
  if (view != null && view instanceof UITextField) {
    return true;
  }
  return false;
}

export const checkTextareaNativeView : CheckTextareaNativeView = function (elementId : string) : boolean {
  const element = uni.getElementById(elementId)
  const view = element?.getIOSView();
  if (view != null && view instanceof UITextView) {
    return true;
  }
  return false;
}

export const checkViewNativeView : CheckViewNativeView = function (elementId : string) : boolean {
  const element = uni.getElementById(elementId)
  const view = element?.getIOSView();
  if (view != null && view instanceof UIView) {
    return true;
  }
  return false;
}
新手
引导
客服 返回
顶部