gpt4 book ai didi

javascript - EMBER—断言失败 : Error while loading route: TypeError: Object [object Object] has no method 'addArrayObserver'

转载 作者:行者123 更新时间:2023-11-30 05:40:55 40 4
gpt4 key购买 nike

当我将所有内容作为数组传递时,我得到了期望的结果,即让我的嵌套路由在父模板中显示它的模板。查看 codepen 简历 page

现在,当我将其转换为夹具数据时,会抛出一个错误:

Assertion failed: Error while loading route: TypeError: Object [object Object] has no method 'addArrayObserver' 

它只会在我将 resume[1] 作为参数传递时中断。我很困惑为什么这在我的笔上有效,我想知道在使用固定装置时如何修复它

afterModel: function(resume, transition) {
this.transitionTo('company', resume[1]);
}

完整代码

App = Ember.Application.create({
LOG_TRANSITIONS: true
});

App.ApplicationAdapter = DS.FixtureAdapter.extend();

// Routes
App.Router.map(function() {
this.resource('resume', function(){
this.resource('company', {path: '/:company_id'});
});
this.route('contact');
});

App.ResumeRoute = Ember.Route.extend({
model: function() {
return this.store.findAll('company');
}
,
afterModel: function(resume, transition) {
this.transitionTo('company', resume[1]);
}
});

App.Company = DS.Model.extend({
companyName: DS.attr(''),
jobTitle: DS.attr(''),
jobDescription: DS.attr(''),
image: DS.attr(''),
dates: DS.attr('')
});

// Model Data
App.Company.FIXTURES = [
{
id: '1',
companyName: 'Brandingbrand',
jobTitle: 'Frontend Web Developer',
jobDescription: 'Branding Brand powers mobile commerce sites and apps for over 200 of the worlds leading retailers, including American Eagle Outfitters, Crate & Barrel, Ralph Lauren, and Sephora. Our transformative technology is proven, reliable, and limitless. Our work is regularly noted by independent research firms, including Forrester and L2. We are also on CrunchBase. And Facebook. And Twitter. The Branding Brand platform scales to meet client goals and supports all forms of smartphone and tablet output. It requires no IT resources, no systems integration, and no web development. Because our inputs are as limitless as our outputs, we can easily transform any aspect of a desktop site into a unique, optimized experience for smartphones, tablets, or in-store. ',
image: 'http://b.vimeocdn.com/ps/103/913/1039135_300.jpg',
dates: 'November 2013 – Current | Pittsburgh Area'
},
{
id: '2',
companyName: 'PPG Industries',
jobTitle: 'Frontend Web Designer',
jobDescription: 'PPG, the worlds leading maker of transportation coatings and a major global supplier of industrial and packaging coatings, flat and fabricated glass, continuous-strand fiber glass, and industrial and specialty chemicals. Our many PPG technologies have been recognized with prestigious R&D 100 Awards and recipients have included. We are also the developers of Transitions® plastic photochromic eyewear lenses that automatically darken when exposed to sunlight. We developed a fiber glass yarn destined to revolutionize the manufacture of circuit boards for computers and other electronic devices Examples of our continuing emphasis on developing high-technology products include.',
image: 'https://www.xeikon.com/sites/default/files/images/ppg-industries.jpeg',
dates: 'August 2012 – August 2013 | Pittsburgh Area'
},
{
id: '3',
companyName: 'Kolano Design',
jobTitle: 'Graphic Designer',
jobDescription: 'Kolano Design is a visual marketing firm, based in Pittsburgh, with expertise in graphics, signage and interiors. The graphics team includes media and communications specialists who create strong corporate identities and adapt them to print, advertising, packaging and web. The signage team includes architects and industrial designers who develop signs that build brands and address complex wayfinding challenges. The interiors team includes designers and product inventors who give shape to high profile corporate and residential spaces and consumer products. We hope you enjoy paging through some of our recent work. Give us a call at 412-661-9000. Call us today.',
image: 'http://pghdesigners.com/images/portfolio/138.jpg',
dates: 'August 2012 – August 2013 | Pittsburgh Area'
},
{
id: '4',
companyName: 'Whirl Magazine',
jobTitle: 'Front End Web Designer',
jobDescription: 'Founded in 2001, WHIRL is Western Pennsylvanias Premier Lifestyle Magazine. Twelve times per year, WHIRL promotes the people, places, and businesses that help Pittsburgh continue to be "Americas Most Livable City." From fundraisers and galas to after-work happy hours, WHIRL provides a behind-the-scenes look at Pittsburghs vibrant social scene. The success of the magazine is founded on the support of the community and WHIRLs goal to showcase the best of Western Pennsylvania living. Since its foundation, WHIRL Magazine has expanded into a multi-faceted publishing company, including the bi-monthly Edible Allegheny, Pittsburghs main resource for local food and farms.',
image: 'http://www.themodernmatchmaker.com/wp-content/uploads/2012/08/whirl-magazine-dating-news-articles.jpg',
dates: 'April 2011 – July 2011 | Pittsburgh Area'
},
{
id: '5',
companyName: 'Pittsburgh Technical Institute',
jobTitle: 'Visual Communications Assistant',
jobDescription: 'Probably the most important advantage for students is the assistance provided by the Career Services department in job search and career assistance. Students can explore employment opportunities on a local, regional and national level through PTI’s network of contacts. All associate degree and many certificate students have the opportunity to experience an industry internship or clinical experience. This further enhances the hands-on experience students enjoy across all programs and builds a strong portfolio. Probably the most important advantage for students is the assistance provided by the Career Services department. This is all without doubt why people come.',
image: 'http://media.prleap.com/image/17002/full/PTI.png',
dates: 'March 2010 – July 2011 | Oakdale PA'
}
];

当我 console.log('company', resume 1 ); — 公司未定义。当我 console.log('resume', resume);和 console.log('company', resume);他们都分别返回:

resume 
Class {type: function, store: Class, isLoaded: true, isUpdating: false, constructor: function…}
__ember1388681292354: "ember270"
__ember1388681292354_meta: Meta
_super: undefined
arrangedContent: (...)
content: (...)
get content: function () {
set content: function (value) {
isLoaded: true
isUpdating: false
store: Class
toString: function () { return ret; }
type: App.Company
__proto__: Object

最佳答案

resume 不是一个数组,它是一个集合,所以 resume[0] 不存在,你应该使用 resume.objectAt(0)

关于javascript - EMBER—断言失败 : Error while loading route: TypeError: Object [object Object] has no method 'addArrayObserver' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20887396/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com