简体   繁体   English

如何避免 [Vue 警告]:您可能在组件渲染 function 中有无限更新循环。 在 VUEJS 中

[英]How can I avoid [Vue warn]: You may have an infinite update loop in a component render function. in VUEJS

How can I avoid infinite update loop in a component render function.如何避免infinite update loop in a component render function. in VUEJS在 VUEJS 中

i create a simple show Password button, with this structure:我创建了一个简单的显示密码按钮,结构如下:

<div class="mt-4 switchContainerGenPassword">
    <div class="switchGeneratePassword">
        <label for="auto_generate_password" class="vs-input--label">{{$t('forms.formNewUser.autoGeneratePassword')}}</label>
        <vs-switch color="success" @change="controlGeneratePassword()" v-model="auto_generate_password" vs-icon="done" name="auto_generate_password" />
    </div>

    <div class="showPassword">
        <button class="showpasswordIcon" :click="controlShowPassword()">
            <vs-icon v-if="showPassword" icon="visibility_off" />
            <vs-icon v-else icon="visibility"></vs-icon>
        </button>
    </div>
    <vs-input class="w-full mt-4" v-model="userUassword" :readonly="auto_generate_password" :type="passwordType" :label="$t('forms.formNewUser.password')" v-validate="'required'" name="password" ref="password" />

    <span class="text-danger text-sm" v-show="errors.has('password')">{{ errors.first('password') }}</span>
</div>

this is my data method这是我的数据方法

  data() {
    return {
      userUassword : "",
      userPasswordConfirmation : "",
      showPassword : false, //check if password is showed or no ,
      passwordType : "password", //input password type 

    }
  },

i have an method named: controlShowPassword()我有一个名为: controlShowPassword()的方法

methods: {
   controlShowPassword(){
       this.passwordType = this.passwordType === 'text' ? 'password' :'text';
   },
}

how can How can I avoid infinite update loop in a component render function ?如何避免infinite update loop in a component render function

Try:尝试:

<button class="showpasswordIcon" @click="controlShowPassword()">
  <vs-icon v-if="showPassword" icon="visibility_off" />
  <vs-icon v-else icon="visibility"></vs-icon>
</button>

Events need to use @ , it's a shorthand for v-on .事件需要使用@ ,它是v-on的简写。

You mustn't use : (shorthand for v-bind ) for events.您不能使用:v-bind的简写)来表示事件。

More details in:更多细节在:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复或抑制误报“组件渲染功能中可能存在无限更新循环” Vue警告 - How to fix or suppress a false positive “You may have an infinite update loop in a component render function” Vue warning 如何修复 Vue 警告:组件渲染函数中可能存在无限更新循环 - How to Fix Vue Warning: You may have an infinite update loop in a component render function Vue组件中的“组件渲染函数中可能存在无限更新循环”警告 - “You may have an infinite update loop in a component render function” warning in Vue component Vue 道具更新 - 您可能在组件渲染函数中有无限更新循环 - Vue props update - You may have an infinite update loop in a component render function Vue.js 警告你可能在组件渲染函数中有无限更新循环 - Vue.js warns You may have an infinite update loop in a component render function 您可能在组件渲染函数中有一个无限的更新循环? - You may have an infinite update loop in a component render function? 即使使用扩展运算符,您也可能在组件渲染 function 中有无限更新循环 - You may have an infinite update loop in a component render function even with spread operator 即使使用扩展运算符,您也可能在组件渲染函数中存在无限更新循环,但 Object.assign 运行良好 - You may have an infinite update loop in a component render function even with spread operator, but Object.assign works well 当我添加这行代码时“您可能在组件渲染函数中有无限更新循环” - console.log(perksTree.slots.unshift()) - “You may have an infinite update loop in a component render function” when I add this line of code - console.log(perksTree.slots.unshift()) Vue触发器中的简单切换功能:您可能有无限的更新循环 - Simple toggle function in Vue trigger: You may have an infinite update loop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM