Example L_div的contenteditable">
赞
踩
<label contenteditable>Example Label</label>正确的用法是 <label contenteditable="true">Example Label</label><div :contenteditable="true" class="content-item" ref="content-item" @input="changeServiceContent">
<span>{{props.setting.serviceContentConfig.text}}</span>
</div>
changeServiceContent(e) {
//解决删除鼠标位置问题
this.$refs["content-item"].focus();
document.execCommand("selectAll", false, null);
document.getSelection().collapseToEnd();
//赋值双向绑定
this.props.setting.serviceContentConfig.text = e.target.textContent;
},
注意:div中的内容如果不用span包裹,鼠标位置可能会有问题
使用contenteditable不能使用change事件,但是可以用input事件和blur事件等。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。