Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

vue的中的方法为什么会死循环

<div id="app">
 <!--<router-view/>-->
 <div class="shortcut-box">
 <div v-for="(item,value,index) in shortcut"
 >
 {{ index }}
      <div :style="setCoordinates(index)">
 </div> </div> </div></div>
 
 
 
 data () {
  return {
    locale: zhCN,
 shortcut: {
      wo: ["55", '11'],
 wo1: ["55", '11'],
 wo2: ["55", '11'],
 wo3: ["55", '11'],
 wo4: ["55", '11'],
 wo5: ["55", '11'],
 wo6: ["55", '11'],
 wo7: ["55", '11']
    },
 count: 0
 }
},
mounted () {
},
methods: {
  setCoordinates: function (index) {
    if (index%4==0) {
      this.count++
      console.log(this.count)
    }
  }
}

这儿的count会无限增加,但是但是数据来说,应该只执行7次就够了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...