Cordova 插件未使用 IONIC 框架定义

标签 cordova ionic-framework visual-studio-2015 cordova-plugins

我遇到了麻烦,没有找到答案,我的对象 windows.cordova.plugin 这个未定义的需要访问键盘,显然我的代码是正确的。我使用 Visual Studio 2015 和最新版本 cordova(5.3) 和 IONIC(1.1)。

提前致谢

HTML

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
</head>
<body ng-app="starter">
    <ion-nav-bar class="bar-stable">
        <ion-nav-back-button>
        </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
</body>
</html>

APP.JS

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider

  .state('login', {
      url: '/login',
      templateUrl: 'templates/login.html',
      controller: 'LoginCtrl'
  })

  .state('home-page', {
    url: '/home',
    templateUrl: 'templates/home.html',
    controller: 'HomeCtrl'
  })

  $urlRouterProvider.otherwise('/login');
});

最佳答案

您可以通过检查文件来检查插件是否已正确安装在平台中

/plugins/{platform}.json

例如,对于 Android,该文件是

/plugins/android.json

并检查installed_plugins

的值
...
"installed_plugins": {
        "com.ionic.keyboard": {
            ...
        },
...
}

关于Cordova 插件未使用 IONIC 框架定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33682465/

相关文章:

javascript - File.dataDirectory 在 Ionic 2 中不起作用

typescript - 如何在电容器的 Electron 结构中使用opencv.js? ReferenceError : cv is not defined

android - PhoneGap/Cordova 中的 Chromecast 支持

client-server - 使用 PhoneGap 并将 UI 保留在服务器上

ios - Cordova - 体系结构 x86_64 的 undefined symbol

angular - ionic 与 SSR 实现

android - android 上的 cordova-plugin-network-information 返回 connection.type = NONE 即使有 4G 连接

"None"的 TypeScript 构建模块系统不会继续存在

c++ - 为什么 "this"在具有多个基类的类的父类中发生变化?

c++ - 结构内的函数原型(prototype) - Intellisense 找不到