div contenteditable="true" 添加placehoder效果

<div class="contain" :style="{height: editableHeight + 'px'}"
v-html="innerText"
ref="editableDiv"
contenteditable="true"
:placeholder=placeholder
@input="inputText"
@blur="inputBlur"
@focus="inputFocus">

 

 

.contain {
width: 100%;
padding: 3px;
border: 1px solid #DCDFE6;
border-radius:4px;
font-size: 12px;
overflow-x: hidden;
overflow-y: auto;
}
.contain:empty::before {
content: attr(placeholder);
color: grey;
}

posted @ 2024-03-05 22:52  BloggerSb  阅读(211)  评论(0编辑  收藏  举报