wangxy 5 місяців тому
батько
коміт
8dc6daf5ff
2 змінених файлів з 19 додано та 3 видалено
  1. 18 3
      components/question/FillItem.vue
  2. 1 0
      pages/unitTest/index.vue

+ 18 - 3
components/question/FillItem.vue

@@ -1,7 +1,7 @@
 <template>
-	<uni-popup background-color="#fff" ref="fillRef">
+	<uni-popup type="top" background-color="#fff" ref="fillRef">
 		<view class="popup-content">
-			<input v-model.trim="result" :focus="true" placeholder="请输入答案" style="width: 100%" @blur="onBlur" type="text" class="input-box" />
+			<input  v-model.trim="result" :focus="true" placeholder="请输入答案"  @blur="onBlur" @confirm="handleConfirm" class="my-textarea" type="text" />
 		</view>
 	</uni-popup>
 </template>
@@ -10,6 +10,7 @@
 	import {ref, watch} from "vue";
 	const fillRef = ref(null);
 	const result = ref('');
+	const focus = ref(false);
 	const emits = defineEmits(['blur']);
 	const props = defineProps({
 		value: {
@@ -26,12 +27,23 @@
 	})
 	
 	function showPopup() {
-		fillRef.value.open('top');
+		fillRef.value.open();
 	}	
+	
+	function handleConfirm() {
+		fillRef.value.close();
+	}
+	
 	function onBlur() {
 		emits("blur", {result: result.value,index: props.index});
+		focus.value = false;
 	}
 	
+	uni.$on("swiper-change", () => {
+		emits("blur", {result: result.value,index: props.index});
+		fillRef.value.close()
+	})
+	
 	defineExpose({
 		showPopup
 	})
@@ -41,4 +53,7 @@
 .popup-content {
 	padding: 20px;
 }
+.my-textarea {
+	height: 36px;
+}
 </style>

+ 1 - 0
pages/unitTest/index.vue

@@ -107,6 +107,7 @@
 	
 	function onSwiperChange(index) {
 		current.value = index;
+		uni.$emit('swiper-change', index)
 	}