我想从 Rotten Tomatoes API 检索电影列表,一切看起来都很好,即使 chrome 没有给我任何错误,但数据没有显示在应用程序上。我将粘贴我的视图、商店和模型,因为我相信它可能会有所帮助。感谢期待回复
tmdbModel.js
Ext.define("cinema.model.tmdbModel", {
extend: 'Ext.data.Model',
xtype: 'top_movies_model',
config: {
fields: [
{name: 'id', mapping: 'movies.id'},
{name: 'title', mapping: 'movies.title'},
{name: 'year', mapping: 'movies.year'},
{name: 'mpaa_rating', mapping: 'movies.mpaa_rating'},
{name: 'runtime', mapping: 'movies.runtime'},
{name: 'critics_consensus', mapping: 'movies.critics_consensus'},
{name: 'release_dates', mapping: 'movies.release_dates.theater'},
{name: 'critics_rating', mapping: 'movies.ratings.critics_rating'},
{name: 'critics_score', mapping: 'movies.ratings.critics_score'},
{name: 'audience_rating', mapping: 'movies.ratings.audience_rating'},
{name: 'synopsis', mapping: 'movies.synopsis'},
{name: 'poster_thumbnail', mapping: 'movies.posters.thumbnail'},
{name: 'poster_profile', mapping: 'movies.posters.profile'},
{name: 'poster_detailed', mapping: 'movies.posters.detailed'},
{name: 'poster_original', mapping: 'movies.posters.original'},
{name: 'abridged_cast_name', mapping: 'movies.abridged_cast.name'},
{name: 'abridged_cast_id', mapping: 'movies.abridged_cast.id'},
{name: 'abridged_cast_characters', mapping: 'movies.abridged_cast.characters'},
{name: 'alternate_ids', mapping: 'movies.alternative_ids.imdb'},
{name: 'links_self', mapping: 'movies.links.self'},
{name: 'links_alternate', mapping: 'movies.links.alternate'},
{name: 'links_cast', mapping: 'movies.links.cast'},
{name: 'links_reviews', mapping: 'movies.links.reviews'},
{name: 'links_similar', mapping: 'movies.links.similar'}
]
}
});
tmdbStore.js
Ext.define("cinema.store.tmdbStore", {
extend: 'Ext.data.Store',
requires: [
'Ext.data.proxy.JsonP',
'cinema.model.tmdbModel',
],
xtype: 'top_movies_store',
config: {
model: 'cinema.model.tmdbModel',
store: {
proxy: {
type: 'jsonp',
url: 'api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?apikey=[myApiKey]',
headers: {
'Accept' : 'application/json'
},
reader: {
type: 'json',
root: 'movies'
},
callbackKey: 'callback',
autoLoad: true
}
}
}
});
Main.js - 查看
Ext.define('cinema.view.Main', {
extend: 'Ext.Container',
xtype: 'main',
requires: ['Ext.TitleBar', 'Ext.DataView', 'cinema.store.tmdbStore'],
config: {
layout: {
type: 'card',
animation: 'slide'
},
defaults: {
baseCls: 'back'
},
animation: 'flip',
items: [
{
xtype: 'titlebar',
title: 'Anakle Cinemas',
docked: 'top',
baseCls: 'flat title_font',
items: [
{
html: '<img src="menu_butn.png">',
cls: 'flat border-right',
padding: '5 15 0 15',
align: 'left',
style: 'height: 100%',
itemId: 'menu_btn',
listeners: {
tap: function (button, e, eOpts) {
var cont = button.getParent().getParent();
cont.setActiveItem(0);
}
}
},
{
html: '<img src="share.png">',
cls: 'flat',
padding: '5 15 0 15',
align: 'right',
style: 'height: 100%',
itemId: 'share_btn'
}
]
},
{
xtype: 'panel',
defaultType: 'button',
//padding: '20 0 0 5',
defaults: {
ui: 'plain',
labelCls: 'btn_label',
cls: 'btn_color flat'
},
items: [
{
text: 'Top Movies',
listeners: {
tap: function (button, e, eOpts) {
var cont = button.getParent().getParent();
cont.setActiveItem(1)
}
}
},
{
text: 'Trailers',
listeners: {
tap: function (button, e, eOpts) {
var cont = button.getParent().getParent();
cont.setActiveItem(2)
}
}
},
{
text: 'Now Showing',
listeners: {
tap: function (button, e, eOpts) {
var cont = button.getParent().getParent();
cont.setActiveItem(3)
}
}
}
]
},
{
xtype: 'panel',
items: [
//{
// xtype: 'titlebar',
//title: 'Top Movies'
// },
{
xtype: 'dataview',
title: 'Top Movies',
store: 'tmdbStore',
styleHTMLContent: true,
itemTpl: new Ext.XTemplate(
'<tpl for=".">',
'<div>{title}</div>',
'</tpl>'
)
}
]
},
{
xtype: 'panel',
html: 'Trailers'
},
{
xtype: 'panel',
html: 'Now Showing'
}
]
}
});
请注意,我是该框架的新手,准确地说只有 1 周。
我没有足够的声誉来发布链接,因此在某些部分“链接”,我将结果限制为 1
{
"movies":
[
{
"id": "771322400",
"title": "The Purge",
"year": 2013,
"mpaa_rating": "R",
"runtime": 85,
"critics_consensus": "Half social allegory, half home-invasion thriller, The Purge attempts to use thriller formula to make an intelligent point -- but ultimately only ends up sinking in numbing violence and tired cliches.",
"release_dates": {
"theater": "2013-06-07"
},
"ratings": {
"critics_rating": "Rotten",
"critics_score": 41,
"audience_rating": "Spilled",
"audience_score": 59
},
"synopsis": "If on one night every year, you could commit any crime without facing consequences, what would you do? In The Purge, a speculative thriller that follows one family over the course of a single night, four people will be tested to see how far they will go to protect themselves when the vicious outside world breaks into their home. In an America wracked by crime and overcrowded prisons, the government has sanctioned an annual 12-hour period in which any and all criminal activity-including murder-becomes legal. The police can't be called. Hospitals suspend help. It's one night when the citizenry regulates itself without thought of punishment. On this night plagued by violence and an epidemic of crime, one family wrestles with the decision of who they will become when a stranger comes knocking. When an intruder breaks into James Sandin's (Ethan Hawke) gated community during the yearly lockdown, he begins a sequence of events that threatens to tear a family apart. Now, it is up to James, his wife, Mary (Lena Headey), and their kids to make it through the night without turning into the monsters from whom they hide. Directed by James DeMonaco (writer of Assault on Precinct 13 and The Negotiator), The Purge is produced by Jason Blum of Blumhouse (Paranormal Activity, Insidious, Sinister), Platinum Dunes' partners Michael Bay, Brad Fuller and Andrew Form (The Amityville Horror, The Texas Chainsaw Massacre), as well as Sebastien Kurt Lemercier (Assault on Precinct 13).(c) Universal",
"posters": {
"thumbnail": "link",
"profile": "link",
"detailed": "link",
"original": "link"
},
"abridged_cast": [
{
"name": "Ethan Hawke",
"id": "162660464",
"characters": [
"James Sandin"
]
},
{
"name": "Lena Headey",
"id": "162653508",
"characters": [
"Mary Sandin"
]
},
{
"name": "Max Burkholder",
"id": "770752375",
"characters": [
"Charlie Sandin"
]
},
{
"name": "Adelaide Kane",
"id": "771075391",
"characters": [
"Zoey Sandin"
]
},
{
"name": "Edwin Hodge",
"id": "770673719",
"characters": [
"Bloody Stranger"
]
}
],
"alternate_ids": {
"imdb": "2184339"
},
"links": {
"self": "link",
"alternate": "link",
"cast": "link",
"clips": "link",
"reviews": "link",
"similar": "link"
}
}
]
}