for里面调用方法 vue_vue.js v-for每次循环两条项目,里面的处理函数会出现重复调用的问题...

本文探讨了在Vue应用中使用v-for循环时遇到的处理函数重复调用问题。当循环体内调用方法时,由于循环次数导致方法被多次触发。文章通过分析代码并提供示例,展示了如何避免这种问题,确保方法只在预期情况下被调用。同时,还介绍了在特定条件下的总页数计算逻辑。
摘要由CSDN通过智能技术生成

<script>

let count = 3

let indexArr = []

export default {

name: 'reportPage',

data () {

return {

tdata: [1,2,3],

myForm: {

'myCompany': '海南凯迪网络资讯股份有限公司',

'myTips': ''

},

totalPage: 4,

}

},

mounted () {

let that = this

let height = document.body.clientHeight - 60

that.$refs.main.style.height = height+'px'

//    alert(((that.tdata.length - 1)%2))

if (that.tdata.length === 1 ) {

that.totalPage = 4

}else {

that.totalPage = 4 + Math.floor((that.tdata.length - 1)/2) + 1

}

//    alert(that.totalPage)

//    if ((that.tdata.length%2) && tdata.length>1) {

//        that.totalPage = 3 + that.tdata.length + 1

//    }else{

//        that.totalPage = 3 + that.tdata.length

//    }

},

methods: {

submitForm (e) {

let that = this

e.preventDefault()

that.form.validateFields((err, values) => {

if (!err) {

console.log('Received values of form: ', values);

}

})

},

textChange () {

let that = this

//          console.log('tips==',that.form.getFieldValue('tips'))

that.myForm.myTips = that.form.getFieldValue('tips')

},

getPageNum (index) {

console.log("index=", index)

//          console.log("count1=",count)

//          if (indexArr.indexOf(index) == -1) {

//              indexArr.push(index)

//              count--

//          }

//          console.log("count2==",count)

//          console.log('sum=', index + count)

//          return index + count

}

}

}

</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值