美文网首页
vue中使用副文本编辑器vue-html5-editor解决图片

vue中使用副文本编辑器vue-html5-editor解决图片

作者: skills | 来源:发表于2017-09-20 10:51 被阅读3288次

我在vue项目中使用vue-html5-editor解决图片上传问题,
只需要将配置图片设置中一项修改后台就可以了,

 // 配置图片模块 
    // config image module 
    image: {
        // 文件最大体积,单位字节  max file size 
        sizeLimit: 512 * 1024,
        // 上传参数,默认把图片转为base64而不上传 
        // upload config,default null and convert image to base64 
        upload: {
            url: '/api/captical',//图片上传路径
            headers: {},
            params: {},
            fieldName: 'file'// 需要修改的地方
        },
 // 响应数据处理,最终返回图片链接 
        // handle response data,return image url 
        uploadHandler(responseText){
            //default accept json data like  {ok:false,msg:"unexpected"} or         {ok:true,data:"image url"} 
            var json = JSON.parse(responseText)
            if (!json.ok) {
                alert(json.msg)
            } else {
                return json.data
            }
        }

这样就ok了

相关文章

网友评论

      本文标题:vue中使用副文本编辑器vue-html5-editor解决图片

      本文链接:https://www.haomeiwen.com/subject/fyawsxtx.html