【问题标题】:Ionic android button not working离子android按钮不起作用
【发布时间】:2016-04-26 18:44:27
【问题描述】:

我的 ionic 应用程序出现问题。我通过 ionic serve 在网络浏览器上编写了整个应用程序。现在我想在安卓设备上发布我的应用。

在网络上一切正常,但是当我尝试在我的 android 4.3 或 5.5 设备上启动应用程序时,当我单击登录页面上的登录按钮时没有任何反应。

这是我的登录模板:

<ion-view view-title="Anmelden" name="login-view">
  <ion-content class="padding">
      <div class="list list-inset">
          <label class="item item-input">
              <input type="text" placeholder="Username" ng-model="data.username">
          </label>
          <label class="item item-input">
              <input type="password" placeholder="Passwort" ng-model="data.password">
          </label>
      </div>
      <button class="button button-block button-positive" ng-click="login(data)">Login</button>
  </ion-content>
</ion-view>

我的路由(简化),在我的app.js中run函数之后:

.config(function ($stateProvider, $urlRouterProvider, USER_ROLES) {
  $stateProvider
  .state('login', {
    url: '/login',
    templateUrl: 'templates/login.html',
    controller: 'LoginCtrl'
  })
  $urlRouterProvider.otherwise('/login');
})

我的 LoginCtrl 中的实际函数没有被调用,所以我假设我的模板不知何故与其路由无关。 该按钮只是显示为死,当您按下它时没有任何反应(还在我的网络服务器上监视传入的 http 请求)。

我也尝试从 ng-click 更改为 on-tap。 有人可以帮助我吗?非常感谢。

问候

【问题讨论】:

    标签: android angularjs button ionic-framework


    【解决方案1】:

    将此添加到index.html 的标题中(参考http://content-security-policy.com/

    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
    

    你应该在你的项目中添加cordova-plugin-whitelist(参考https://github.com/apache/cordova-plugin-whitelist

    cordova plugin add cordova-plugin-whitelist
    

    然后将以下行添加到您的config.xml

    <access origin="*" />
    <allow-intent href="*" />
    

    【讨论】:

    • 完美 :-) 就是这样。
    猜你喜欢
    • 2017-11-04
    • 2021-12-06
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-31
    相关资源
    最近更新 更多