项目中,已实现封装百度编辑器组件。这里,是为了增加支持自定义插入商品等服务功能。
新增自定义按钮,实现与父级组件通信
initEditor () {
let that = this
window.UE.registerUI('goodsmenu', function (editor, uiName) {
return new window.UE.ui.Button({
name: uiName,
title: '服务', // 这里是设置当鼠标指向这个按扭时显示的文字
cssRules: "background-position: -550px 44px;",
onclick: function () {
// todo 这里使用that.emit传递,父组件无法接收到抛出事件??
// todo 或者是that.parent不起作用 建议都试一下
// that.parent.ueditorMenuOpen()
that.$emit('ueditorMenuOpen')
// alert('我是新增按扭在被点击时执行的方法,在这里可以编写你想要实现的功能哦!');
}
});
});
}
}
父级组件实现选择商品等服务,并插入到编辑器中
<template>
<div>
<!-- 百度编辑器vue组件 -->
<VueUEditor :ueditorPath="ueditorP