vue-editor-oss
v1.0.1
Published
support using v-model and upload oss in vue
Downloads
2
Maintainers
Readme
vue-editor-oss
an editor that can use v-model and upload file to oss for vue
Install
use npm
$ npm install vue-editor-oss -S
documents
v-model使用
<template>
<div>
<vue-editor-oss v-model="html"></vue-editor-oss>
</div>
</template>
...
import VueEditorOss from '@daily/vue-editor-oss'
...
components: {
VueEditorOss
},
data () {
return {
html: ''
}
}
options
参数 | 类型 | 作用 | 默认值 ---|---|---|--- custom-config | Object |继承wangEditor中customConfig | { menus, onchange } oss-access-token |Object |上传文件到阿里云所需的配置 | 需使用者传入,必须的属性:['policy', 'accessid', 'callback', 'token', 'acl', 'signature', 'host', 'dir']
具体配置如下:
customConfig与wangEditor 配置一样,直传,更多配置前往此官网
例如:
const menus = [
'head', // 标题
'bold', // 粗体
'fontSize', // 字号
'fontName', // 字体
'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
'backColor', // 背景颜色
'link', // 插入链接
'list', // 列表
'justify', // 对齐方式
'quote', // 引用
'emoticon', // 表情
'image', // 插入图片
'table', // 表格
'code', // 插入代码
'undo', // 撤销
'redo' // 重复
]
// 组件内默认设置了两个属性,自定义可覆盖
customConfig = {
menus,
onchange // 富文本编辑器内容发生变化时,需要做的处理,内部利用该方法封装好v-model
}
ossAccessToken: 若需要上传图片到oss,可使用此配置
// 需传入的参数配置为:
ossAccessToken = {
policy: '对应oss的policy',
accessid: '对应oss的OSSAccessKeyId',
callback: '对应oss的callback',
token: '对应oss的x-oss-security-token',
acl: '对应oss的x-oss-object-acl',
signature: '对应oss的signature',
host: '上传到oss的域名',
dir: '上传到oss下的位置路径'
},
// 如下面的例子
{
accessid: "STS.NUvvB1XotASGYYrTwf51fPZYN"
host: "https://daily-static.oss-cn-hangzhou.aliyuncs.com"
token: "CAIS/gF1q6Ft5B2yfSjIr5bDPfiFtbBV9pGsW3/DsHczOb5Kv5/yrDz2IHhOenJvBOkatvU0nmtY6/YYlqJ4T55IQ1D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