简体   繁体   English

从URL添加SVG渲染黑色图像

[英]Add SVG from URL render black image

I have a this SVG , which i am trying to load in canvas but it just render the black image, so how to solve it? 我有一个此SVG ,我正尝试在画布中加载它,但它仅呈现黑色图像,那么如何解决呢?

version: 2.0.0-beta.7 版本:2.0.0-beta.7

I have tried both method loadSVGFromString as well as loadSVGFromURL but no success: 我已经尝试了loadSVGFromString方法和loadSVGFromURL方法,但是都没有成功:

//Using loadSVGFromString
var a = 'svg string';
fabric.loadSVGFromString(a,function(objects, options) {
  var obj = fabric.util.groupSVGElements(objects, options);
    canvas.add(obj).renderAll();
});

//using loadSVGFromURL
fabric.loadSVGFromURL('URL Here', function(objects,options) {
    var group = new fabric.Group(objects, {
        left: 50,
        top: 50,
    });
    canvas.add(group);
    canvas.renderAll();
});

checkout this codepen 签出此密码笔

"All black" svgs often is a result of some invalid or unsupported svg markup. “全黑” svg通常是某些无效或不受支持的svg标记的结果。 In your case I think you should remove the fill-opacity="null" references from your svg. 就您而言,我认为您应该从svg中删除fill-opacity="null"引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM