USER-20230908AJ\Administrator пре 1 година
родитељ
комит
ce0baafd31
1 измењених фајлова са 18 додато и 15 уклоњено
  1. 18 15
      pages/index/index.vue

+ 18 - 15
pages/index/index.vue

@@ -1,14 +1,17 @@
 <template>
-    <view>监听到的内容:{{ inputString }}</view>
-	
-	<view class="">
-		--------------------分割线-----------------------------
-	</view>
-	<view class="">
-		{{text}}
-	</view>
+<view>
+  <view>监听到的内容:{{ inputString }}</view>
+
+  <view class="">
+    --------------------分割线-----------------------------
+  </view>
+  
+  <view class="">
+    {{text}}
+  </view>
+</view>
 </template>
- 
+
 <script>
 export default {
   data() {
@@ -19,12 +22,12 @@ export default {
     };
   },
   methods: {
-    onConfirm(code) {
-      console.log('拿到的code', code);
+    onConfirm(text) {
+      console.log('拿到的text', text);
       // 此处写我们自己的逻辑
+      this.text = text;
     },
     keypress(e) {
-		this.text = e;
       if (e.keyCode === 66 || e.key === 'Enter') {
         this.inputString = this.inputCache;
         this.onConfirm(this.inputString);
@@ -37,7 +40,7 @@ export default {
   mounted() {
     // #ifdef APP-PLUS
     plus.key.addEventListener("keyup", this.keypress);
-    // #endif 
+    // #endif
     // #ifdef H5
     document.addEventListener("keyup", this.keypress);
     // #endif
@@ -45,7 +48,7 @@ export default {
   beforeDestroy() {
     // #ifdef APP-PLUS
     plus.key.removeEventListener("keyup", this.keypress);
-    // #endif 
+    // #endif
     // #ifdef H5
     document.removeEventListener("keyup", this.keypress);
     // #endif
@@ -53,7 +56,7 @@ export default {
   deactivated() {
     // #ifdef APP-PLUS
     plus.key.removeEventListener("keyup", this.keypress);
-    // #endif 
+    // #endif
     // #ifdef H5
     document.removeEventListener("keyup", this.keypress);
     // #endif