错误现象:提示“正在加载图像,请稍后。。。”
然后使用chrome打开svg文件,报错提示:This page contains the following errors:
error on line 56 at column 59: Namespace prefix xlink for href on use is not defined
Below is a rendering of the page up to the first error.
解决方法:
在命名空间上添加:xmlns:xlink=”http://www.w3.org/1999/xlink”
例如:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" > <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/> <image xlink:href="happy-every-day.jpg" width="96" height="96" /> </svg>
好像还有其他方法