File tree Expand file tree Collapse file tree 2 files changed +29
-14
lines changed Expand file tree Collapse file tree 2 files changed +29
-14
lines changed Original file line number Diff line number Diff line change 3434 @update:value =" updatePwd" ></switch-option >
3535 <switch-option class =" item" name =" show eye" :value =" showEye"
3636 @update:value =" updateShowEye" v-if =" isPwd" ></switch-option >
37+ <switch-option class =" item" name =" reverse" :value =" reverse"
38+ @update:value =" updateReverse" v-if =" isPwd && showEye" ></switch-option >
3739 <switch-option class =" item" name =" password visible" :value =" pwdVisible"
3840 @update:value =" updatePwdVisible" v-if =" isPwd && showEye" ></switch-option >
3941 </div >
5759 readonly: false ,
5860 isPwd: true ,
5961 showEye: true ,
60- pwdVisible: true
62+ pwdVisible: true ,
63+ reverse: false
6164 }
6265 },
6366 computed: {
6467 eye () {
6568 if (this .isPwd && this .showEye ) {
6669 return {
67- open: this .pwdVisible
70+ open: this .pwdVisible ,
71+ reverse: this .reverse
6872 }
6973 } else {
7074 return false
9094 },
9195 updatePwdVisible (val ) {
9296 this .pwdVisible = val
97+ },
98+ updateReverse (val ) {
99+ this .reverse = val
93100 }
94101 },
95102 components: {
Original file line number Diff line number Diff line change 8484 return {
8585 inputValue: this .value ,
8686 isFocus: false ,
87- pwdVisible: false
87+ formatedEye: {
88+ open: false ,
89+ reverse: false
90+ }
8891 }
8992 },
9093 computed: {
9194 _type () {
9295 const type = this .type
93- if (type === ' password' && this .pwdVisible ) {
96+ if (type === ' password' && this .formatedEye . open ) {
9497 return ' text'
9598 }
9699 return type
102105 return this .type === ' password' && this .eye && ! this .disabled
103106 },
104107 eyeClass () {
105- return this .pwdVisible ? ' cubeic-eye-invisible' : ' cubeic-eye-visible'
108+ const eye = this .formatedEye
109+ let shouleBeVisible = ! eye .open
110+ if (eye .reverse ) {
111+ shouleBeVisible = ! shouleBeVisible
112+ }
113+ return shouleBeVisible ? ' cubeic-eye-visible' : ' cubeic-eye-invisible'
106114 }
107115 },
108116 watch: {
112120 inputValue (newValue ) {
113121 this .$emit (EVENT_INPUT , newValue)
114122 },
115- eye () {
116- this ._computedPwdVisible ()
123+ eye: {
124+ handler () {
125+ this .formateEye ()
126+ },
127+ immediate: true
117128 }
118129 },
119- created () {
120- this ._computedPwdVisible ()
121- },
122130 methods: {
123131 changeHander (e ) {
124132 this .$emit (EVENT_CHANGE , e)
125133 },
126- _computedPwdVisible () {
134+ formateEye () {
127135 if (typeof this .eye === ' boolean' ) {
128- this .pwdVisible = this .eye
136+ this .formatedEye . open = this .eye
129137 } else {
130- this .pwdVisible = this .eye . open
138+ Object . assign ( this .formatedEye , this .eye )
131139 }
132140 },
133141 handleFocus (e ) {
143151 this .$refs .input .focus ()
144152 },
145153 handlePwdEye () {
146- this .pwdVisible = ! this .pwdVisible
154+ this .formatedEye . open = ! this .formatedEye . open
147155 }
148156 }
149157 }
You can’t perform that action at this time.
0 commit comments