喻文俊 3 年 前
コミット
7ae1d3e138
1 ファイル変更12 行追加13 行削除
  1. 12 13
      components/cm-module/cm-search/cm-search.vue

+ 12 - 13
components/cm-module/cm-search/cm-search.vue

@@ -7,8 +7,7 @@
                     type="text"
                     confirm-type="search"
                     :placeholder="placeholder"
-                    :value="keyword"
-                    @input="$emit('input', $event.target.value)"
+                    v-model="inputValue"
                     :focus="true"
                 />
                 <text v-if="clearable && inputValue" class="clearable iconfont icon-quxiao" @click="clearValue"></text>
@@ -29,22 +28,12 @@
 <script>
 export default {
     name: 'CmSearch',
-    model: {
-        prop: 'keyword',
-    },
-
     props: {
         // 占位字符
         placeholder: {
             type: String,
             default: '请输入搜索关键字'
         },
-        // 绑定值
-        keyword: {
-            type: [String, Number],
-            default: ''
-        },
-
         clearable: {
             type: Boolean,
             default: true
@@ -65,10 +54,20 @@ export default {
             default: true
         }
     },
+    watch:{
+        inputValue(nVal){
+            this.$emit('input', nVal)
+        }
+    },
+    data(){
+        return {
+            inputValue: ''
+        }
+    },
     methods: {
         clearValue() {
             this.inputValue = ''
-            this.$emit('change', '')
+            this.$emit('input', '')
         },
         handleClick() {
             if (!this.disabled) return