提交 b57f0a46 编写于 作者: Q qiang

fix: input/textarea use modelValue

上级 ca48f93f
......@@ -76,6 +76,10 @@ export const props = /*#__PURE__*/ Object.assign(
type: String,
default: '',
},
modelValue: {
type: [String, Number],
default: '',
},
value: {
type: [String, Number],
default: '',
......@@ -139,7 +143,14 @@ export const props = /*#__PURE__*/ Object.assign(
keyboardProps
)
export const emit = ['input', 'focus', 'blur', ...keyboardEmit]
export const emit = [
'input',
'focus',
'blur',
'update:value',
'update:modelValue',
...keyboardEmit,
]
type Props = Record<keyof typeof props, any>
......@@ -176,7 +187,7 @@ function useBase(
var maxlength = Number(props.maxlength)
return isNaN(maxlength) ? 140 : maxlength
})
const value = getValueString(props.value)
const value = getValueString(props.modelValue || props.value)
const state: State = reactive({
value,
valueOrigin: value,
......@@ -211,8 +222,10 @@ function useValueSync(
const valueChangeFn = debounce((val: any) => {
state.value = getValueString(val)
}, 100)
watch(() => props.modelValue, valueChangeFn)
watch(() => props.value, valueChangeFn)
const triggerInputFn = throttle((event: Event, detail: InputEventDetail) => {
emit('update:modelValue', detail.value)
emit('update:value', detail.value)
trigger('input', event, detail)
}, 100)
......
......@@ -2777,6 +2777,10 @@ const props$j = /* @__PURE__ */ Object.assign({}, {
type: String,
default: ""
},
modelValue: {
type: [String, Number],
default: ""
},
value: {
type: [String, Number],
default: ""
......@@ -2834,7 +2838,7 @@ const props$j = /* @__PURE__ */ Object.assign({}, {
default: "done"
}
}, props$m);
const emit = ["input", "focus", "blur", ...emit$1];
const emit = ["input", "focus", "blur", "update:value", "update:modelValue", ...emit$1];
function useBase(props2, rootRef, emit2) {
const fieldRef = vue.ref(null);
const trigger = useCustomEvent(rootRef, emit2);
......@@ -2854,7 +2858,7 @@ function useBase(props2, rootRef, emit2) {
var maxlength2 = Number(props2.maxlength);
return isNaN(maxlength2) ? 140 : maxlength2;
});
const value = getValueString(props2.value);
const value = getValueString(props2.modelValue || props2.value);
const state = vue.reactive({
value,
valueOrigin: value,
......@@ -2877,8 +2881,10 @@ function useValueSync(props2, state, emit2, trigger) {
const valueChangeFn = uniShared.debounce((val) => {
state.value = getValueString(val);
}, 100);
vue.watch(() => props2.modelValue, valueChangeFn);
vue.watch(() => props2.value, valueChangeFn);
const triggerInputFn = throttle((event, detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
trigger("input", event, detail);
}, 100);
......
......@@ -4541,6 +4541,10 @@ const props$q = /* @__PURE__ */ Object.assign({}, {
type: String,
default: ""
},
modelValue: {
type: [String, Number],
default: ""
},
value: {
type: [String, Number],
default: ""
......@@ -4598,7 +4602,7 @@ const props$q = /* @__PURE__ */ Object.assign({}, {
default: "done"
}
}, props$t);
const emit = ["input", "focus", "blur", ...emit$1];
const emit = ["input", "focus", "blur", "update:value", "update:modelValue", ...emit$1];
function useBase(props2, rootRef, emit2) {
const fieldRef = ref(null);
const trigger = useCustomEvent(rootRef, emit2);
......@@ -4618,7 +4622,7 @@ function useBase(props2, rootRef, emit2) {
var maxlength2 = Number(props2.maxlength);
return isNaN(maxlength2) ? 140 : maxlength2;
});
const value = getValueString(props2.value);
const value = getValueString(props2.modelValue || props2.value);
const state2 = reactive({
value,
valueOrigin: value,
......@@ -4641,8 +4645,10 @@ function useValueSync(props2, state2, emit2, trigger) {
const valueChangeFn = debounce((val) => {
state2.value = getValueString(val);
}, 100);
watch(() => props2.modelValue, valueChangeFn);
watch(() => props2.value, valueChangeFn);
const triggerInputFn = throttle((event, detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
trigger("input", event, detail);
}, 100);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册