我有以下代碼有問題。
button在我的模板中單擊 my 后,我的counter將增加。現在我想檢查 mycounter是否高于、低于或等于length陣列的 a。
完成后for-loops我想將我的counter背部設定為零。
我試過return this.counter = 0- 但這沒有用。
在此先感謝您幫助我!
methods: {
if(this.counter > this.lengthArray) {
for(let i = this.lengthArray; i <= this.counter; i ) {
//Do some code
}
} else if (this.lengthArray > this.counter) {
for(let i = 1; i <= this.counter; i ) {
//Do some code as well
}
} else if (counter == 0) {
//Process another code
}
},
data() {
return {
counter: 0
}
}
uj5u.com熱心網友回復:
您不希望該方法為returnvalue this.counter = 0。
this.counter = 0在您的最后一個條件之后設定應該有效。沒有什么應該回傳或打破回圈。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/322695.html
標籤:javascript Vue.js 循环 Vuejs2
上一篇:JavascriptlocalStoragefor回圈的問題
下一篇:不使用串列突變洗掉重復項
