本文介绍了使用sencha touch和phonegap时json无法加载到iPhone设备中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将json加载到我的视图中.我在sencha touch上使用phonegap,当我将应用程序加载到手机上时,json根本无法加载.在浏览器和模拟器中都可以正常工作.我非常感谢专家的帮助

I'm trying to load a json into my view. Im using phonegap with sencha touch and when I load the app to my phone the json does not load at all.. It works fine in the browser and in the simulator.I would really appreciate some help from the experts

这是我正在尝试的主要代码:

Here is the main code that im trying:

商店:

App.stores.freebees =新的Ext.data.Store({ 型号:"Freebee", autoLoad:是的, 代理人: { 类型:"ajax", url:装置/freebees", 读者:{ 类型:"json" } }});

App.stores.freebees = new Ext.data.Store({ model: 'Freebee', autoLoad: true, proxy: { type: 'ajax', url: 'fixtures/freebees', reader: { type: 'json' } }});

列表视图:

App.views.FreebeesList = Ext.extend(Ext.List,{ id:"indexlist", 布局:合适", 商店:App.stores.freebees, itemTpl:'{companyName},{title},{address}'

App.views.FreebeesList = Ext.extend(Ext.List, { id: 'indexlist', layout: 'fit', store: App.stores.freebees, itemTpl: '{companyName}, {title}, {address}',

listeners: {
    'itemtap': function(list, index, item, obj) {
        Ext.dispatch({
            controller: 'Freebee',
            action: 'showDetails',
            id: list.getRecord(item).data.id,
            lat: list.getRecord(item).data.lat,
            longitude: list.getRecord(item).data.longitude,
            companyName: list.getRecord(item).data.companyName,
            address: list.getRecord(item).data.address,

        });
    }
},
initComponent: function() {
    App.views.FreebeesList.superclass.initComponent.apply(this, arguments);
}

});Ext.reg('App.views.FreebeesList',App.views.FreebeesList);

});Ext.reg('App.views.FreebeesList', App.views.FreebeesList);

json:

[ { "id":1 "title":"Freebee 1", "companyName":FöretagetAB 1", "address":Ekuddsvägen1 Nacka 131 38 Sweden", "lat":59.3058, 经度":18.1463 }, { "id":2 "title":"Freebee 2", "companyName":FöretagetAB 2", "address":Ekuddsvägen2 Nacka 131 38 Sweden", "lat":59.305, 经度":18.1478 }]

[ { "id": 1, "title": "Freebee 1", "companyName": "Företaget AB 1", "address": "Ekuddsvägen 1 Nacka 131 38 Sweden", "lat": 59.3058, "longitude": 18.1463 }, { "id": 2, "title": "Freebee 2", "companyName": "Företaget AB 2", "address": "Ekuddsvägen 2 Nacka 131 38 Sweden", "lat": 59.305, "longitude": 18.1478 }]

推荐答案

我也遇到了类似的错误.请在此处查看我的问题和答案:

I had a similar error.. Please see my question and answer here:

Sencha解析JSON在iPhone模拟器中,但在iPhone上则不行-phonegap

这篇关于使用sencha touch和phonegap时json无法加载到iPhone设备中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:58