/**
* 读取svg文件
* @filePath:svg文件路径
*/
const readFile = (filePath) => {
// 创建一个新的xhr对象
let xhr = null;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
const okStatus = document.location.protocol === "file" ? 0 : 200;
xhr.open("GET", filePath, false);
xhr.overrideMimeType("image/svg+xml");
xhr.send(null);
return xhr.status === okStatus ? xhr.responseText : null;
};
vue读取SVG
最新推荐文章于 2024-05-14 23:51:42 发布