vue-quill-editor的a标签打开方式问题
vue-quill-editor编辑器如何自定义a标签的target属性,使其可以更改为_self或者_blank
回答:
html部分
<quill-editor :content="content" :options="editorOption" @change="onEditorChange($event)" /> <el-dialog class="link-dialog" title="网址" :visible.sync="visible">
<el-form :model="form">
<el-form-item label="目标网址">
<el-input class="input-href" v-model="form.href"></el-input>
</el-form-item>
<el-form-item label="打开方式">
<el-select class="select-target" v-model="form.target">
<el-option v-for="item in form.targetOptions" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button id="confirm-btn" type="primary" @click="visible = false">确定</el-button>
</div>
</el-dialog>
js部分
class MyLink extends Link { static create(value) {
let node = super.create(value)
node.setAttribute('href', value)
node.setAttribute('target', that.form.target)
return node
}
}
Quill.register(MyLink, true)
// link 配置
link: function (value) {
if (value) {
that.visible = true
var btn = document.getElementById('confirm-btn')
btn.addEventListener('click', () => {
this.quill.format('link', that.form.href)
})
} else {
this.quill.format('link', false)
}
},
以上是 vue-quill-editor的a标签打开方式问题 的全部内容, 来源链接: utcz.com/p/936101.html