【发布时间】:2018-04-07 20:51:15
【问题描述】:
当我尝试在我的移动应用程序中使用 JSONStore 时,我在移动浏览器模拟器中遇到 WL.JSONStore is undefined 错误。我使用的是 IBM mobilefirst(版本 8.0.0-2017091111)。
function wlCommonInit(){
WL.JSONStore.init(collections, options).then(function () {
alert("intialized successfully");
}).fail(function (errorObject) {
alert("failed to initialize collection\n"+ JSON.stringify(errorObject));
});
document.getElementById("btn_submit").addEventListener("click", onSubmit, false);
}
function onSubmit(){
var collectionName="people";
var data={firstName:$('#first').val(),middleName:$('#middle').val(),lastName:$('#last').val()};
WL.JSONStore.get(collectionName).add(data, options).then(function () {
alert("added data successfully");
}).fail(function (error) {
});
}
【问题讨论】:
-
如果项目缺少 JSONStore 插件或 JSONStore 初始化尚未完成,则可能会发生这种情况。您可以在这里试用示例:mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/… 看看您是否遇到同样的问题?