IBM Worklight v6.1.0.1:将Ionic Framework与Worklight一起使用并在IOS环境中运行时出错 [英] IBM Worklight v6.1.0.1 : Error when using Ionic Framework with Worklight and run on IOS environment

查看:144
本文介绍了IBM Worklight v6.1.0.1:将Ionic Framework与Worklight一起使用并在IOS环境中运行时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Ionic Worklight 创建了演示应用,并且它在 Android 上工作但在 IOS 时出错,当我使用移动浏览器模拟器并在IOS环境中调试时,我收到以下错误消息:

I have created demo app using Ionic with Worklight and it worked on Android but got error on IOS, when i used mobile browser simulator and debugged on IOS environment, i got the folowing error message:

未捕获InvalidCharacterError:执行失败'添加''DOMTokenList':提供的令牌('platform-ios-iphone')包含HTML空格字符,这些字符在令牌中无效。

Uncaught InvalidCharacterError: Failed to execute 'add' on 'DOMTokenList': The token provided ('platform-ios - iphone') contains HTML space characters, which are not valid in tokens.

我只是在index.html中添加Ionic文件:

I just add Ionic files in index.html:

<!DOCTYPE HTML>
<html>
        <head>
            <meta charset="UTF-8">
            <title>index</title>
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
            <link rel="shortcut icon" href="images/favicon.png">
            <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
            <link rel="stylesheet" href="css/main.css">
            <link rel="stylesheet" href="ionic/css/ionic.css">
            <script src="ionic/js/ionic.bundle.js"></script>
        </head>
        <body style="display: none;">
            <!--application UI goes here-->
            <div class="bar bar-header bar-positive">
                <h1 class="title">bar-positive</h1>
            </div>
            <script src="js/initOptions.js"></script>
            <script src="js/main.js"></script>
            <script src="js/messages.js"></script>
        </body>
</html>

我还在Android和IOS上的移动设备上测试过,只在IOS设备上出错。

I also tested on mobile device on both Android and IOS and only got error on IOS device.

我不知道如何解决这个问题。有人可以帮忙吗?谢谢。

I don't know how to fix this. Can anyone help? Thanks.

推荐答案

更新5月28日:这是一篇关于Worklight和Ionic的博客文章示例项目: http:/ /mobileroly.blogspot.co.il/2014/04/using-angular-js-and-ionic-on-ibm.html

update May 28th: here is a blog post about Worklight and Ionic with a full sample project: http://mobileroly.blogspot.co.il/2014/04/using-angular-js-and-ionic-on-ibm.html

好吧,这似乎是离子框架和Worklight之间的一些不兼容。

Worklight不正式支持离子。

Well, this seems like some incompatibility between the ionic framework and Worklight.
Worklight does not officially support ionic.

MBS发送ios - iphone。

离子又不喜欢这样,因为有空格......

The MBS sends "ios - iphone".
ionic in turn does not like that because there are spaces...

我不太清楚离子期望在那里有什么,但你可以通过在ionic.bundle.js文件中找到这个代码来克服错误:

I don't quite know what ionic expects to have there, but you can overcome the error by finding this code in the ionic.bundle.js file:

for(var i = 0; i < ionic.Platform.platforms.length; i++) {
    document.body.classList.add('platform-' + ionic.Platform.platforms[i]);
}

并将其替换为以下内容。

错误将消失。

And replacing it with the following.
The error will be gone.

for(var i = 0; i < ionic.Platform.platforms.length; i++) {
    if (ionic.Platform.platforms[i] = "ios - iphone") {
       document.body.classList.add('platform-ios');  
       // or maybe 'platform-ready', I don't know...
    } else {
       document.body.classList.add('platform-' + ionic.Platform.platforms[i]);
    }
}

然而,这对显示应用程序没有帮助在MBS中...

但至少你可以在Xcode的iOS模拟器中运行以查看应用程序。

This, however, does not help in displaying the app in the MBS...
But at least you can then run in Xcode's iOS Simulator to see the app.

似乎离子和Worklight的iPhone / iPad环境不能很好地协同工作。

It seems that ionic and Worklight's iPhone/iPad environments don't play well together.

index.html:

<head>
    ...
    ...
    <link href="ionic/ionic.css" rel="stylesheet">
    <script src="ionic/ionic.bundle.js"></script>
</head>

<body ng-app="ionicApp">
    <div class="bar bar-header bar-positive">
        <h1 class="title">bar-positive</h1>
    </div>
    <div style="margin-top:38px">
        <p>test test test</p>
    </div>
    ...
    ...
</body>

main.js:

angular.module('ionicApp', ['ionic']);

这篇关于IBM Worklight v6.1.0.1:将Ionic Framework与Worklight一起使用并在IOS环境中运行时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆