Vue组件方法解析 - 重置密码、角色选择和样式变更
这是一个Vue组件的methods部分,包含了以下几个方法:
- onResetPass:重置密码方法,会根据用户输入的账号和角色信息,调用API接口进行密码重置,并提示重置成功。
methods: {
async onResetPass() {
if(this.username==undefined) {
this.$utils.msg('请输入账号')
return;
}
if(this.optionsValues[this.index]=='') {
this.$utils.msg('请选择角色')
return;
}
let res = await this.$api.resetPass(`${this.optionsValues[this.index]}`, this.username)
this.$utils.msgBack('重置密码成功,原始密码为:123456')
},
...
}
- optionsChange:角色选择框改变事件,会根据用户选择的角色索引值,更新组件中的index值。
methods: {
...
optionsChange(e) {
this.index = e.target.value
},
...
}
- styleChange:样式改变事件,会根据组件中的restPwFrom.content.input.backgroundColor属性,更新组件中所有输入框的背景颜色。但是这个方法被注释掉了,实际上并没有起到作用。
methods: {
...
styleChange() {
this.$nextTick(()=>{
// document.querySelectorAll('.forget-input .uni-input-input').forEach(el=>{
// el.style.backgroundColor = this.restPwFrom.content.input.backgroundColor
// })
})
},
...
}
原文地址: https://www.cveoy.top/t/topic/gQcV 著作权归作者所有。请勿转载和采集!