Skip to content

Commit ddea9e6

Browse files
committed
Chromium 连字问题 workaround
1 parent 74938a4 commit ddea9e6

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/components/dataBlockInner/strInputs.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<template>
2-
<div v-for="input in fnType.inputs" class="input-box">
2+
<div v-for="(input, index) in fnType.inputs" class="input-box">
33
<span class="input-title styled">{{ t(input.title) }}</span>
44
<s-text-field
5-
v-model="dataItem[input.value]"
5+
v-model.trim="dataItem[input.value]"
66
:label="t(input.placeholder)"
77
class="styled"
8+
ref="inputBox"
9+
@blur="handleBlur(index)"
810
>
911
</s-text-field>
1012
</div>
@@ -15,7 +17,19 @@ import { useI18n } from "vue-i18n";
1517
const { t } = useI18n();
1618
1719
import { InputProps } from "../../consts";
20+
import { ref } from "vue";
1821
const { dataItem, fnType } = defineProps<InputProps>();
22+
23+
const inputBox = ref<HTMLElementTagNameMap["s-text-field"][]>();
24+
25+
// Chromium 文本框输入三个字形以上的连字时渲染不生效
26+
// 需要在失去焦点时手动添加空格再删除以触发渲染
27+
28+
function handleBlur(index: number) {
29+
inputBox.value![index].value = inputBox.value![index].value + " ";
30+
inputBox.value![index].value = inputBox.value![index].value.trim();
31+
}
32+
const emit = defineEmits(["blur"]);
1933
</script>
2034

2135
<style>

0 commit comments

Comments
 (0)