小编Nas*_*zah的帖子

打字稿中的 window.webkit

我需要将 javascript 代码重写为 typescript (angular),网页由 IOS 应用程序或 Android 应用程序打开。我只想向应用程序发送消息。

如何向父应用程序发送消息或如何使用window.webkit

notifyTheApp(postData) {
  if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
    if(window.webkit.messageHandlers)      
     window.webkit.messageHandlers.mpos.postMessage(JSON.stringify(postData));
    } 
    else {
      if(window.external.notify)
        window.external.notify(JSON.stringify(postData));
    }

Run Code Online (Sandbox Code Playgroud)

mpos 是iOS应用

src/app/sms-validation/sms-validation.component.ts(98,17) 中的错误:错误 TS2339:“窗口”类型上不存在属性“webkit”。

javascript webkit typescript angular

3
推荐指数
1
解决办法
4511
查看次数

标签 统计

angular ×1

javascript ×1

typescript ×1

webkit ×1