<template>
    <div style="padding: 0 20px">
        <wike_md
                v-model="val"
                ref="md"
                @on-ready="onReady"
                @on-upload-image="onUpladImage"
                @on-save="onSave"
                :height="800"
        ></wike_md>
    </div>
</template>

<script>
    import wike_md from  './src/components/md/index'
    import  axios from  'axios';
    export default {
        components: {
            wike_md
        },
        mounted() {

        },
        data: function () {
            return {
                val: '',
                vm:null
            }
        },
        methods: {
            onReady({vm}) {
               this.vm=vm

            },
            onUpladImage(file) {
                //let formData = new FormData()
                // file就是后台接收的key
                //formData.append('file', file, file.name)
                // 将formdata发送到后台即可
                // axios.post('服务器地址', formData).then((data) => {
                //     console.log(data)
                //     this.$refs.md.insertContent('\n![image](' + data.data.url + ')');
                // })
                this.vm.instance.insertImage("http://csdn.52wike.com/wike.jpeg");
            },
            onSave(data) {
                console.log(data);//编辑器md内容
            },
        }
    }
</script>

<style lang="less">

</style>
