【问题标题】:t.resolve is not a function in ionic 4t.resolve 不是 ionic 4 中的函数
【发布时间】:2019-06-05 01:47:41
【问题描述】:

我的用例:

在特定页面的 Ionic 4 中从 JS 文件(包含在项目中)调用 JavaScript 函数。

我遇到以下问题。

ERROR TypeError: t.resolve is not a function
at Object.setNativePromise (polyfills.js:3)
at L.configurable.L.set (polyfills.js:3)
at n.exports (ocw.js:4850)
at a (ocw.js:4850)
at Object.209.100 (ocw.js:4851)
at s (ocw.js:4850)
at ocw.js:4850
at Object.327.131 (ocw.js:4852)
at s (ocw.js:4850)
at ocw.js:4850

后续步骤:

  1. src->assets下包含的JS文件
  2. 在cordova.js 文件后的index.html 中添加了引用

<!-- cordova.js required for cordova apps (remove if not needed) -->
  <!-- <script src="assets/ocw.js"></script> -->
  <script src="cordova.js"></script>
  
  <script src="assets/ocw.js"></script>
  1. 在所需文件中,将变量声明为函数名
  2. 在ionViewDidLoad下调用javascript函数

离子设置:

离子:

离子(离子 CLI):4.1.2(/usr/local/lib/node_modules/ionic) 离子框架:离子角 3.9.2 @ionic/app-scripts:3.2.0

科尔多瓦:

科尔多瓦(科尔多瓦 CLI):8.0.0 Cordova 平台:android 6.4.0,ios 4.5.5 Cordova 插件:cordova-plugin-ionic-keyboard 2.1.2、cordova-plugin-ionic-webview 2.0.2(和其他 9 个插件)

系统:

ios 部署:1.9.2 ios-sim : 6.0.0 NodeJS : v8.12.0 (/usr/local/bin/node) npm:6.4.1 操作系统:macOS Xcode:Xcode 10.1 构建版本 10B61

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    您需要在您的 javascript 文件中 export 函数,然后在 pagename.page.tsimport 才能使用它。

    【讨论】:

    • 感谢您的回复。我也试过这个。它在我的登录页面上工作正常,但如果我尝试将它放在任何其他页面上,我会收到同样的错误
    • @GirishFuluskar 您需要为每个要使用它的页面导入它。
    猜你喜欢
    • 2020-04-12
    • 1970-01-01
    • 2019-07-17
    • 1970-01-01
    • 2018-07-08
    • 2018-04-09
    • 2020-02-12
    • 2019-08-01
    • 1970-01-01
    相关资源
    最近更新 更多