Ver Fonte

添加v-model:value双向绑定的支持 (#1073)

无需在Change事件中修改绑定的Value。
仅需在属性中设置 v-model:value,选择图标后,value值自动修改。
RemMai há 3 anos atrás
pai
commit
b07003e184
1 ficheiros alterados com 5 adições e 2 exclusões
  1. 5 2
      src/components/Icon/src/IconPicker.vue

+ 5 - 2
src/components/Icon/src/IconPicker.vue

@@ -121,7 +121,7 @@
       copy: propTypes.bool.def(false),
       mode: propTypes.oneOf<('svg' | 'iconify')[]>(['svg', 'iconify']).def('iconify'),
     },
-    emits: ['change'],
+    emits: ['change', 'update:value'],
     setup(props, { emit }) {
       const isSvgMode = props.mode === 'svg';
       const icons = isSvgMode ? getSvgIcons() : getIcons();
@@ -148,7 +148,10 @@
 
       watch(
         () => currentSelect.value,
-        (v) => emit('change', v)
+        (v) => {
+          emit('update:value', v);
+          return emit('change', v);
+        }
       );
 
       function handlePageChange(page: number) {