fix:文本框组件,格式框有时不显示问题

This commit is contained in:
wangjiahao 2021-10-09 11:58:27 +08:00
parent c427e548c0
commit 66f6a726cd

View File

@ -2,6 +2,7 @@
<div v-if="editMode == 'edit'" class="v-text" @keydown="handleKeydown" @keyup="handleKeyup"> <div v-if="editMode == 'edit'" class="v-text" @keydown="handleKeydown" @keyup="handleKeyup">
<!-- tabindex >= 0 使得双击时聚集该元素 --> <!-- tabindex >= 0 使得双击时聚集该元素 -->
<div <div
v-if="canEdit"
ref="text" ref="text"
:contenteditable="canEdit" :contenteditable="canEdit"
:class="{ canEdit }" :class="{ canEdit }"
@ -14,6 +15,7 @@
@input="handleInput" @input="handleInput"
v-html="element.propValue" v-html="element.propValue"
/> />
<div v-if="!canEdit" :style="{ verticalAlign: element.style.verticalAlign }" @dblclick="setEdit" v-html="element.propValue" />
</div> </div>
<div v-else class="v-text"> <div v-else class="v-text">
<div :style="{ verticalAlign: element.style.verticalAlign }" v-html="element.propValue" /> <div :style="{ verticalAlign: element.style.verticalAlign }" v-html="element.propValue" />
@ -110,6 +112,10 @@ export default {
setEdit() { setEdit() {
this.canEdit = true this.canEdit = true
// // //
// setTimeout(() => {
// this.$refs['text'].focus()
// }, 500)
// //
this.selectText(this.$refs.text) this.selectText(this.$refs.text)
}, },