[英]IBM Worklight 6.0 - JSONStore error in preview after migrating from Worklight 5.0.6
I have an app that makes use of the JSONStore in v5.0.6. 我有一个使用v5.0.6中的JSONStore的应用程序。
I migrated the project over to v6.0 and tried to use the Mobile Browser Simulator to test the JSONStore functionality. 我将项目迁移到v6.0,并尝试使用移动浏览器模拟器来测试JSONStore功能。
I added WL.Client.getEnvironment() === 'preview'
to the if
condition in my collection JavaScript file. 我在集合JavaScript文件的
if
条件中添加了WL.Client.getEnvironment() === 'preview'
。
However, when I try to get an instance of the collection, I get an error: 但是,当我尝试获取集合的实例时,出现错误:
TypeError: WL.profileCollection is undefined
TypeError:WL.profileCollection未定义
I think this maybe because the following API does not exist in version 6? 我认为这可能是因为版本6中不存在以下API?
WL.namespace('WL.profileCollection');
WL.namespace('WL.profileCollection');
What is the workaround for this problem? 解决此问题的方法是什么?
Try: 尝试:
var WL = WL || {};
WL.profileCollection = WL.profileCollection || {};
//rest of your code
Remove: WL.namespace('WL.profileCollection');
删除:
WL.namespace('WL.profileCollection');
A defect was opened to add WL.namespace
back to the code, the work around is above. 已打开一个缺陷以将
WL.namespace
添加回代码中, WL.namespace
已在上面。
Make sure you remove any if statements preventing the code from getting executed: 确保删除所有阻止执行代码的if语句:
if (WL.Client.getEnvironment() === 'android' && ...) { ... }
or make sure you add the preview/common environment to those if statements. 或确保将预览/公共环境添加到这些if语句中。 Before Worklight 6.0 JSONStore was only supported on Android and iOS environments, that's why the Wizard generated those if statements by default.
在Worklight 6.0之前,仅在Android和iOS环境上支持JSONStore,这就是向导默认情况下生成那些if语句的原因。 With Worklight 6.0 there's a compatible JavaScript-only API available for developing JSONStore applications faster.
使用Worklight 6.0,可以使用兼容的纯JavaScript API,以更快地开发JSONStore应用程序。 More on the What's new section inside IBM Information Center .
有关IBM Information Center中的“新增功能”部分的更多信息 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.