Browse Source

全局修改选择如果value与label都为数字0则清空

wolyshaw 4 years ago
parent
commit
21e15d0090
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/main.js

+ 12 - 1
src/main.js

@@ -44,9 +44,20 @@ class DonMessage {
   }
 }
 
-// 修改默认属性 
+// 修改默认属性
 ElementUI.Dialog.props.closeOnClickModal.default = false;
 // ElementUI.Dialog.props.destroyOnClose.default = true;
+
+// 全局修改选择如果value与label都为数字0则清空
+const SelectValueWatch = ElementUI.Select.watch.value
+ElementUI.Select.watch.value = function (newValue, oldValue) {
+  SelectValueWatch.call(this, newValue, oldValue)
+  if(this.selected && this.selected.value === 0 && this.selected.currentLabel === 0 && newValue !== oldValue) {
+    this.handleClearClick.call(this, {
+      stopPropagation: () => {}
+    })
+  }
+}
 Vue.use(ElementUI)
 // 命名根据需要,DonMessage只是在文章中使用
 export const $message = new DonMessage()