저는 Sencha Touch로 시작하여 2.2.1 버전에서 작업하고 있습니다. 웬일인지, 나는 나의 json에게 올바르게 해석 할 수 없다. 내 크롬 개발자 도구에서 json을 볼 수 있기 때문에 응답 문제가 아님을 알고 있습니다.로컬 json을 구문 분석 할 수 없습니다.
여기 여기 내 store
Ext.define('MyApp.store.Tasks', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.Task'
],
config: {
autoLoad: true,
storeId: 'tasksStore',
model: 'MyApp.model.Task',
proxy: {
type: 'ajax',
url: 'tasks.json',
reader: {
type: 'json',
rootProperty: 'tasks'
}
}
}
});
입니다 내 상점을 테스트하는 Jasmine
을 사용하고 내 Model
Ext.define('MyApp.model.Task', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'task', type: 'string', defaultValue: 'task' }
]
}
});
입니다. 내 사양은 여기
describe('MyApp.store.Tasks', function() {
it('Number of tasks should be four', function() {
var store = Ext.create('MyApp.store.Tasks');
expect(store.getCount()).toBe(4);
});
});
그리고 여기 내 샘플 json
파일이 있습니다. 그것은 Sencha의 index.html
파일과 같은 디렉토리에 있으며 루트 디렉토리입니다.
{
"tasks":[
{
"task":"Some Product",
"id":0
},
{
"task":"Another Product",
"id":1
},
{
"task":"A third product",
"id":2
},
{
"task":"A fourth product",
"id":3
}
]
}
인스턴스화 문제 때문입니까? 아니면 여기서 중요한 부분을 놓치고 있습니까? 프록시 유형에 대해 jsonp를 시도했지만 응답 주위에 래퍼가 필요하며이를 수행하는 방법을 잘 모릅니다. Safari와 Chrome에서 모두 테스트 중이지만 불행히도 두 브라우저 모두에서 단위 테스트가 실패합니다.
감사합니다.
매우 좋음을 의미합니다. 설명! 고맙습니다! – javaCity