Sfoglia il codice sorgente

延迟获取焦点

xiaohaizhao 2 anni fa
parent
commit
45ae9f070c
1 ha cambiato i file con 12 aggiunte e 5 eliminazioni
  1. 12 5
      pages/index/modules/mine.vue

+ 12 - 5
pages/index/modules/mine.vue

@@ -130,14 +130,13 @@
 			</view>
 		</u-popup>
 		<u-overlay :show="showPopup" zIndex="9997" @click="showPopup = false" />
-
-		<u-modal :show="changeUser.showModal" @confirm="changeUserMsg" @cancel="changeUser.showModal = false"
-			showCancelButton ref="uModal" :asyncClose="true">
+		<u-modal :show="changeUser.showModal" @confirm="changeUserMsg" @cancel="onCancel" showCancelButton ref="uModal"
+			:asyncClose="true">
 			<view class="modal-content">
 				<view class="title">
 					修改{{ changeUser.title }}
 				</view>
-				<input :focus="changeUser.showModal" class="input" v-model="changeUser.changeValue" type="text"
+				<input :focus="inputFocus" class="input" v-model="changeUser.changeValue" type="text"
 					:placeholder="changeUser.placeholder" />
 			</view>
 		</u-modal>
@@ -180,6 +179,7 @@ export default {
 			userMsg: {},
 			showPopup: false,
 			spaceUsage: 0,
+			inputFocus: "",
 			changeUser: {
 				name: "",
 				showModal: false,
@@ -204,6 +204,13 @@ export default {
 				changeValue: "",
 				placeholder: value || placeholder,
 			}
+			setTimeout(() => {
+				this.inputFocus = true
+			}, 100)
+		},
+		onCancel() {
+			this.changeUser.showModal = false
+			this.inputFocus = false
 		},
 		/* 修改用户信息 */
 		changeUserMsg() {
@@ -228,7 +235,7 @@ export default {
 				if (this.cutoff(res.msg, '修改成功')) return;
 				this.userMsg.name = content.name;
 				this.userMsg.hr.email && (this.userMsg.hr.email = content.email);
-				this.changeUser.showModal = false;
+				this.onCancel();
 				this.getUserMsg();
 			})
 		},