Javascript 余烬组件在生产中崩溃

Javascript 余烬组件在生产中崩溃,javascript,ember.js,digital-ocean,Javascript,Ember.js,Digital Ocean,当我在生产环境中使用ember-service构建ember应用程序时,我的ember应用程序出现了问题,所有组件都工作得很好,但当我使用Ubuntu 16.04将其部署到我的Digital Ocean droplet中时,该应用程序只使用一个组件崩溃 这里有崩溃组件的代码: import Ember from 'ember'; import pagedArray from 'ember-cli-pagination/computed/paged-array'; export default

当我在生产环境中使用
ember-service
构建ember应用程序时,我的ember应用程序出现了问题,所有组件都工作得很好,但当我使用Ubuntu 16.04将其部署到我的Digital Ocean droplet中时,该应用程序只使用一个组件崩溃

这里有崩溃组件的代码:

import Ember from 'ember';
import pagedArray from 'ember-cli-pagination/computed/paged-array';

export default Ember.Component.extend({
  init(){
    this._super(...arguments);
    this.send('fillQuestions');
  },
  didDestroyElement(){
    this.send('reset');
  },
  last: false,
  toggleModal: false,
  aciertos: 0,
  errores: 0,
  contenido: Ember.computed('questions', function () {
    let i = 0,
        content = [],
        contenido = [];
    for (i; i < this.get('questions.length'); i++) {
      content.push(this.get('questions.' + i + '.id_question_group.questions'));
    }

    contenido = [].concat.apply([], content);
    return contenido;
  }),
  count: 0,
  page: 1,
  perPage: 1,
  pagedContent: pagedArray('contenido', {
    pageBinding: "page",
    perPageBinding: "perPage"
  }),
  totalPagesBinding: "pagedContent.totalPages", 
  progressValue: 0,
  color: Ember.computed('count', function () {
    return new Ember.String.htmlSafe("width: " + this.get('progressValue') + "%;");
  }),
  actions: {
    ...(all my actions)
  }
});

带有
this.set()
的行产生了问题,这是因为
questions[i].questionID.description
空路径
有没有一种方法可以在组件中创建具有相同操作的新属性?

我终于找到了错误,组件尝试设置新属性时显示错误

真正的问题是: 当我试图保存问题的属性时,一些问题得到了“.”并且似乎
Ember.computed
不允许将它们用于属性,因此当我尝试
this.set('some.question.with.dots','')时,
触发了错误并显示
属性集失败

解决方案很简单,我只需要使用javascript的
.replace()
函数来替换字符串中的所有点

最终代码如下:

actions: {
    ...
    fillQuestions(){
        let questions = this.get('contenido'); //Filled with exam questions
        for(let i = 0; i < questions.length; i++){
            if(questions[i].questionID !== null && questions[i].questionID !== undefined){
                let desc = questions[i].questionID.description.replace(/\./g,'');
                this.set(desc, ''); //the problem has gone
            }
        }
    }
    ...
}
操作:{
...
补充问题(){
让问题=this.get('contenido');//充满考试问题
for(设i=0;i

感谢所有以他们的观点支持我的人。

我终于找到了错误,当组件尝试设置新属性时,错误显示出来

真正的问题是: 当我试图保存问题的属性时,一些问题得到了“.”并且似乎
Ember.computed
不允许将它们用于属性,因此当我尝试
this.set('some.question.with.dots','')时,
触发了错误并显示
属性集失败

解决方案很简单,我只需要使用javascript的
.replace()
函数来替换字符串中的所有点

最终代码如下:

actions: {
    ...
    fillQuestions(){
        let questions = this.get('contenido'); //Filled with exam questions
        for(let i = 0; i < questions.length; i++){
            if(questions[i].questionID !== null && questions[i].questionID !== undefined){
                let desc = questions[i].questionID.description.replace(/\./g,'');
                this.set(desc, ''); //the problem has gone
            }
        }
    }
    ...
}
操作:{
...
补充问题(){
让问题=this.get('contenido');//充满考试问题
for(设i=0;i

感谢所有支持我观点的人。

你的考试时间是在进入倒计时时设置的吗?您可以添加一个
{{log exam.duration}
来检查…@acorncom日志显示
{{exam.duration}
它不是空的,我将尝试查找模板中的所有变量,可能是其中一个。您有一个依赖于自身的CP,循环可疑:
contenido:Ember.computed('contenido'
@锁我忘了更新它,我已经纠正了,
Ember.computed
它正在查找'questions',这是从路由传递的属性。如果您想将description属性定义为空,那么就不要将
this.set(questions[I].question-id.description')
,您可以尝试
Ember.set(questions>)[i] .questionID,'description','')
。在您的情况下,
此.set
将在组件中创建新属性,此处不需要此属性,因为您没有将其用作属性而不是数组。持续时间是在将其传递到倒计时时设置的。您可以添加
{log exam.duration}
要检查…@acorncom日志显示
{{exam.duration}
它不是空的,我将尝试查找模板中的所有变量,可能是其中之一。您有一个依赖于自身的CP,它循环可疑:
contenido:Ember.computed('contenido'
@锁我忘了更新它,我已经纠正了,
Ember.computed
它正在查找'questions',这是从路由传递的属性。如果您想将description属性定义为空,那么就不要将
this.set(questions[I].question-id.description')
,您可以尝试
Ember.set(questions>)[i] .questionID,'description','')
。在您的情况下,
此.set将在组件中创建新属性,此处不需要此属性,因为您没有将其用作属性而不是数组
actions: {
    ...
    fillQuestions(){
        let questions = this.get('contenido'); //Filled with exam questions
        for(let i = 0; i < questions.length; i++){
            if(questions[i].questionID !== null && questions[i].questionID !== undefined){
                let desc = questions[i].questionID.description.replace(/\./g,'');
                this.set(desc, ''); //the problem has gone
            }
        }
    }
    ...
}