[英]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.