我试图用SVG图片替换IMG标签中嵌入的内容,并将其作为内联输出。换句话说,加载给定IMG SRC属性的SVG文件的内容到变量中,并将其注入HTML中作为内联SVG,如下所示:
显然是 get 函数的问题吗?
提前致谢。
...
else if (type && type === 'img-simple') {
if (format === 'svg' ) {
$.get(src, function(data) {
var svg = $(data);
$bg.append(svg);
});
} else {
...
其中,变量类型为图像类,格式为图像类型:jpg、sag等。
这会导致以下错误:
[Error] Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. (img01.svg, line 0)
[Error] XMLHttpRequest cannot load file:///Users/img01.svg. Origin null is not allowed by Access-Control-Allow-Origin. (index.html, line 0)
显然是 get 函数的问题吗?
提前致谢。