当前位置:   article > 正文

报错 You may have an infinite update loop in a component render function.

you may have an infinite update loop in a component render function.

问题出现原因:动态变换数据的时候,我将变换的内容写在了其他函数中导致报You may have an infinite update loop in a component render function.(你可以在组件呈现函数中有一个无限更新循环。)

错误代码: 

  1. <el-tooltip class="item" content="创建费后指数" placement="top">  
  2.   <el-button class="mr-10" :disabled="!showControlType(scope.row)" type="text" @click="showAfterFeesIndexDialog(scope.row)"></el-button>  
  3. </el-tooltip>  
  4. <el-tooltip class="item" :content="showMoveCommonIndexIcon ? '移出常用指数' : '加入常用指数'" placement="top">  
  5.   <el-link type="primary" class="mr-10" :class="showMoveCommonIndexIcon?'el-icon-document-delete':'el-icon-document-add'" :underline="false" @click="moveCommonIndexHandler(scope.row)" />  
  6. </el-tooltip>
  7. data(){
  8. return {
  9. showMoveCommonIndexIcon:"
  10. }
  11. }
  12. mehtods:{
  13. showControlType(row) {  
  14.   const label = row.label  
  15.   if (label) {  
  16.     const labelArr = label.split(',')  
  17.     const showControlType = labelArr.some(_ => {  
  18.       return _ === '组合指数' || _ === '我的指数' || _ === '费后指数'  
  19.     })  
  20.     const showMoveCommonIndexIcon = labelArr.includes('常用指数')  
  21.      this.showMoveCommonIndexIcon = showMoveCommonIndexIcon
  22.     return showControlType  
  23.   }  
  24. }
  25. }

我将动态判断showMoveCommonIndexIcon 的代码写在了另一个动态判断的函数showControlType中导致报错

解决方法:就是将动态判断的代码写在自己的函数中

  1. <el-tooltip class="item" :content="showMoveCommonIndexIcon(scope.row) ? '移出常用指数' : '加入常用指数'" placement="top">
  2. <el-link type="primary" class="mr-10" :class="showMoveCommonIndexIcon(scope.row)?'el-icon-document-delete':'el-icon-document-add'" :underline="false" @click="moveCommonIndexHandler(scope.row)" />
  3. </el-tooltip>
  4. showMoveCommonIndexIcon(row) {
  5. const label = row.label
  6. if (label) {
  7. const labelArr = label.split(',')
  8. const showMoveCommonIndexIcon = labelArr.includes('常用指数')
  9. return showMoveCommonIndexIcon
  10. }
  11. },

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/402368
推荐阅读
相关标签
  

闽ICP备14008679号