<div class="content-container" ref="contentContainer">
<div v-if="flag" ref="ContentEditable"> <div v-for="(item,index) in data" :key="index" class="each-editable" contenteditable="true" v-html="item"></div> </div>
</div>
<script>
data(){
flag:false
},
mounted(){
this.bindInputEvent()
},
methods:{
bindInputEvent(){
this.$refs.contentContainer.oninput = function(event){
// 执行操作
}
}
}
</script>
flag改变为true时,可编辑框绑定的@input事件始终没有触发。最后做了事件委托,搞定。
标签:vue,contenteditable,绑定,flag,input,true,bindInputEvent From: https://www.cnblogs.com/junlinglife/p/16805807.html