如何使行长度不超过10?

时间:2016-04-09 00:26:07

标签: vue.js

这是我的小提琴。 https://jsfiddle.net/7nxhygLp/20/

methods:{
  addRow: function(){
    for(var i=0; i < this.number; i++){
      this.rows.push({});
    }
  },

如何制作,以使行长不超过10?

2 个答案:

答案 0 :(得分:2)

methods:{

  addRow: function(){

    for(var i=0; i < this.number && i < 10; i++){

      this.rows.push({});

    }

},

答案 1 :(得分:0)

任何寻找答案的人。 你可以回顾这个小提琴。

https://jsfiddle.net/7nxhygLp/21/

 methods:{
  addRow: function(){
    this.number = parseInt(this.number);
            if(total + this.number <= 10)
    {
                        total += this.number;
                        for(var i=0; i < this.number; i++){
                      this.rows.push({});
                    }
      }
  }
相关问题