提交 047e4aca 编写于 作者: W wangjinxin613 提交者: DCloud-WZF

feat(uni-app): input、textarea 组件暴露 $triggerInput 方法

上级 3bb5f11d
......@@ -35,7 +35,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
class: UniInputElement,
},
//#endif
setup(props, { emit }) {
setup(props, { emit, expose }) {
const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password', 'tel']
const AUTOCOMPLETES = ['off', 'one-time-code']
const type = computed(() => {
......@@ -171,6 +171,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({
!props.confirmHold && input.blur()
}
expose({
$triggerInput: (detail: { value: string }) => {
emit('update:modelValue', detail.value)
emit('update:value', detail.value)
state.value = detail.value
},
})
//#if _X_ && !_NODE_JS_
onMounted(() => {
const rootElement = rootRef.value as UniInputElement
......
......@@ -56,7 +56,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
class: UniTextareaElement,
},
//#endif
setup(props, { emit }) {
setup(props, { emit, expose }) {
const rootRef: Ref<HTMLElement | null> = ref(null)
const wrapperRef: Ref<HTMLElement | null> = ref(null)
const { fieldRef, state, scopedAttrsState, fixDisabledColor, trigger } =
......@@ -124,6 +124,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({
setFixMargin()
}
expose({
$triggerInput: (detail: { value: string }) => {
emit('update:modelValue', detail.value)
emit('update:value', detail.value)
state.value = detail.value
},
})
//#if _X_ && !_NODE_JS_
onMounted(() => {
const rootElement = rootRef.value as UniTextareaElement
......
......@@ -3561,7 +3561,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
props: props$j,
emits: ["confirm", ...emit],
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"];
......@@ -3664,6 +3665,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
});
!props2.confirmHold && input.blur();
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => {
let inputNode = props2.disabled && fixDisabledColor ? vue.createVNode("input", {
"key": "disabled-input",
......@@ -7361,7 +7369,8 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
props: props$a,
emits: ["confirm", "linechange", ...emit],
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const rootRef = vue.ref(null);
const wrapperRef = vue.ref(null);
......@@ -7423,6 +7432,13 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
!props2.confirmHold && textarea.blur();
}
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => {
let textareaNode = props2.disabled && fixDisabledColor ? vue.createVNode("textarea", {
"key": "disabled-textarea",
......
......@@ -9754,7 +9754,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
class: UniInputElement
},
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"];
......@@ -9857,6 +9858,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
});
!props2.confirmHold && input.blur();
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
onMounted(() => {
const rootElement = rootRef.value;
Object.defineProperty(rootElement, "value", {
......@@ -15238,7 +15246,8 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({
class: UniTextareaElement
},
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const rootRef = ref(null);
const wrapperRef = ref(null);
......@@ -15303,6 +15312,13 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({
{
setFixMargin();
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
onMounted(() => {
const rootElement = rootRef.value;
Object.defineProperty(rootElement, "value", {
......
......@@ -3504,7 +3504,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
props: props$j,
emits: ["confirm", ...emit],
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"];
......@@ -3607,6 +3608,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
});
!props2.confirmHold && input.blur();
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => {
let inputNode = props2.disabled && fixDisabledColor ? vue.createVNode("input", {
"key": "disabled-input",
......@@ -7288,7 +7296,8 @@ const index$g = /* @__PURE__ */ defineBuiltInComponent({
props: props$a,
emits: ["confirm", "linechange", ...emit],
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const rootRef = vue.ref(null);
const wrapperRef = vue.ref(null);
......@@ -7350,6 +7359,13 @@ const index$g = /* @__PURE__ */ defineBuiltInComponent({
!props2.confirmHold && textarea.blur();
}
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => {
let textareaNode = props2.disabled && fixDisabledColor ? vue.createVNode("textarea", {
"key": "disabled-textarea",
......
......@@ -9681,7 +9681,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
props: props$q,
emits: ["confirm", ...emit],
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"];
......@@ -9784,6 +9785,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
});
!props2.confirmHold && input.blur();
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
return () => {
let inputNode = props2.disabled && fixDisabledColor ? createVNode("input", {
"key": "disabled-input",
......@@ -14883,7 +14891,8 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
props: props$h,
emits: ["confirm", "linechange", ...emit],
setup(props2, {
emit: emit2
emit: emit2,
expose
}) {
const rootRef = ref(null);
const wrapperRef = ref(null);
......@@ -14948,6 +14957,13 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
{
setFixMargin();
}
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
return () => {
let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
"key": "disabled-textarea",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册