富文本编辑器

  • 如果和crud组件或则from组件使用自定义卡槽的方式
<!-- oss导入需要的包 (一定要放到index.html中的head标签里) -->
<script type="text/javascript" src='https://cdn.staticfile.org/ali-oss/6.10.0/aliyun-oss-sdk.min.js'></script>
<script src="https://avuejs.com/cdn/CryptoJS.js"></script>

代码

代码地址open in new window

新特性

  • 基于wangeditor二次开发
  • 支持avue方式配置图片上传
  • 支持七牛云和阿里云oss上传
  • 支持粘贴和ctrl+v粘贴图片

使用

  • 1.npm install avue-plugin-ueditor@next --save
  • 2.import AvueUeditor from 'avue-plugin-ueditor'
  • 3.Vue.use(AvueUeditor);
  • 4.参考如下代码使用
<h1 class="ql-align-center" style="text-align: center;"><a href="https://avuejs.com/doc/plugins/ueditor-plugins" target="_blank" style="font-weight: bold; color: rgb(194, 79, 74);">欢迎使用Avue富文本编辑器</a></h1><p class="ql-align-center" style="text-align: center;"><span style="font-weight: bold; color: rgb(194, 79, 74);"><img src="https://avuejs.com/images/logo-bg.jpg" height="200" width="200"></span></p>
<avue-ueditor v-model="text"
              v-bind="options"></avue-ueditor>
<span class="avue-ueditor__code">{{text}}</span>
<script>
import avueUeditor from 'avue-plugin-ueditor'
export default {
  component:{
    avueUeditor
  },
  data() {
    return {
      text: '<h1 class="ql-align-center" style="text-align: center;"><a href="https://avuejs.com/doc/plugins/ueditor-plugins" target="_blank" style="font-weight: bold; color: rgb(194, 79, 74);">欢迎使用Avue富文本编辑器</a></h1><p class="ql-align-center" style="text-align: center;"><span style="font-weight: bold; color: rgb(194, 79, 74);"><img src="https://avuejs.com/images/logo.png" height="200" width="200"></span></p>',
      options: {
        //普通上传地址
        action: "https://api.avuejs.com/imgupload",
        customConfig: {},//wangEditor编辑的配置
        //是否启用oss(qiniu/ali)
        oss:'',
        headers:{},
        data:{},
        propsHttp: {
          home:'',
          url:'url',
          res: 'data'
        },
        //七牛云oss配置
        qiniu: {
          AK: "",
          SK: "",
          scope: "",
          url: "",
          deadline: 1
        },
        //阿里云oss配置
        ali: {
          region: "",
          endpoint: "",
          accessKeyId: "",
          accessKeySecret: "",
          bucket: ""
        }
      }
    };
  }
};
</script>

upload Attributes

参数说明类型可选值默认值
action图片上传地址String-
headers上传附带请求头数据Object-
data上传附带数据Object-
props相关可配置参数,具体参考props配置Object-
oss是否使用oss不写则为普通上传Stringali/qiniu-
qiniu七牛云oss配置,具体参考qiniu配置Object-
ali阿里云oss配置,具体参考ali配置Object-

propsHttp Attributes

参数说明类型可选值默认值
res返回的数据结构层次String-
url返回结构体图片地址字段String-
home图片的根路径地址String-

qiniu Attributes

参数说明类型可选值默认值
AK七牛云的密钥String-
SK七牛云的密钥String-
scope七牛云存储的空间名String-
url空间的自定义域名String-
deadlinetoken的过期时间String-

ali Attributes

参数说明类型可选值默认值
regionoss所在区域的名称,具体查看阿里云oss文档String-
endpointoss所在区域的域名,具体查看阿里云oss文档String-
accessKeyId阿里云的密钥String-
accessKeySecret阿里云的密钥String-
bucket阿里云存储的空间名String-
Last Updated:
Contributors: smallwei
您正在浏览基于Avue 3.x文档; 点击这里 查看Avue 2.x 的文档