<--封装成组件-->
<template>
<div style="display: inline">
<span class="span-edit" ref="pp" :style="styleObj" :contenteditable="contenteditable" @focus="isFocus = true" @blur="isFocus = false" @keyup="inputHandle"></span>
<span v-if="!value" style="border-bottom: 1px solid #696969" @click="moveCursor">{
{ tip }}</span>
</div>
</template>
<script>
export default {
props: {
value: {
type: String,
default: ''
},
contenteditable: {
type: Boolean,
default: true
},
tip: {
type: String,
default: '请输入内容'
}
},
data() {
return {
isFocus: true,
innerText: this.value
}
},
computed: {
styleObj() {
return {
'b
模拟input效果实现随文字内容增加宽度自适应(vue)
于 2022-05-17 15:31:38 首次发布