1.html代码片段
<div class="quill-editor"
ref='textfocus'
@focus="parentidfocus"
style="width:100%;height:330px;"
v-model="content"
v-quill:myQuillEditor="editorOption"
></div>
<button class="btnrepey fr" @click="backrepley">回复</button>
// 点击回复时获取到富文本框的焦点
2.methods
parentidfocus() {
this.textfocusrow = false
this.parentid = 0
},
backrepley(){
this.$nextTick(function(){
console.log(this.$refs.textfocus) // 输出如图
console.log(this.$refs.textfocus.querySelector('.ql-blank'))
setTimeout(() => {
// this.$refs.textfocus.focus()
/*
* 刚开始直接调用,发现无法调用,实际是focus外头还包一层,所以以后可以审查一下元素
*/
this.$refs.textfocus.querySelector('.ql-blank').focus()
this.$refs.textfocus.click()
}, 0);
})
},
3.输出的内容,可以看的出来两个console.log()出来嵌套的层级关系