vue整合editor.md解决多个editor.md同时共存问题v-model数据绑定
点击下载demo
定义editor.md为vue组件
安装 scriptjs
cnpm install --save scriptjs
在components文件夹下面创建一个组件
<template>
<div class="markdown-editor-box">
<link rel="stylesheet" href="/editormd/css/editormd.min.css">
<div :id="editorId"></div>
</div>
</template>
<script>
function uuid () {
let s = []
let hexDigits = '0123456789abcdef'
for (let i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
}
s[14] = '4'
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1)
s[8] = s[13] = s[18] = s[23] = '-'
return s.join('')
}
export default {
model: {
prop: 'content',
event: 'onChangeContent'
},
props: {
show: {
type: Boolean,
default: false
},
tag: {
type: String,
default: uuid()
},
editorId: {
type: String,
default: uuid()
},
onchange: {
type: Function
},
config: {
type: Object
},
content: {
type: String,
default: ''
},
delay: {
type: Number,
default: 0
}
},
data: function () {
return {
editor: null