Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript c、 mvc、主干网、定时器_Javascript_Backbone.js - Fatal编程技术网

Javascript c、 mvc、主干网、定时器

Javascript c、 mvc、主干网、定时器,javascript,backbone.js,Javascript,Backbone.js,我正在尝试创建多个计时器。任何可以帮助我的教程。最困难的部分是html部分,如何链接我的文件一个示例项目会对我有好处 Html5.Views.Timer = Backbone.View.extend({ el: 'div#timer', initialize: function() { timer = this.model; this.render(); }, events: { "clicked div#add_time": "update_tim

我正在尝试创建多个计时器。任何可以帮助我的教程。最困难的部分是html部分,如何链接我的文件一个示例项目会对我有好处

Html5.Views.Timer = Backbone.View.extend({

  el: 'div#timer',

  initialize: function() {
    timer = this.model;
    this.render();
  },

  events: {
    "clicked div#add_time": "update_timer"
  }

  render: function() {
    $(this.el).append(HandlebarsTemplates['timer'](timer);
    this.start_timer();
  },

  start_timer: function() {
    clearTimeout(this.main_timer); 
    this.main_timer = setTimeout(function()  {
      if (this.countDownInstance) {
        this.countDownInstance.clearRewriteCounter();
      }
      this.countDownInstance = new countDown(timed.length, 'main_timer');
    }, timed_length*1000);
  },

  update_timer: function() {
    timed.length = timed.length+30
    this.start_timer();
  }
});

我认为有一个输入错误,或者你使用timed_length或者你使用timed.length。。另外,我认为timed.length应该返回一个错误,至少在全局范围中有一个名为timed的变量

此外,测线计时器=this.model;正在全局范围中声明变量计时器

另外,对timed_length的调用可能需要将其更改为this.timed_length


总结。。我认为这里有很多拼写错误。

现在这对像我这样的毕业开发人员来说变得复杂了。你能为我重写上面的代码公平吗?对不起@ak47你应该努力一下。timed_length:function{if this.seconds>0 | this.minutes>0{this.seconds=this.seconds-1;if this.seconds==0{this.minutes=this.minutes-1;this.seconds=59;}else{this.seconds=this.seconds-1;}}但它仍然不能工作:我已经放弃了倒计时: