ionic-framework - Miragejs:无法加载离子图标 - data:image/svg+xml
问题描述
在浏览器控制台中出现以下错误并且图标未呈现。
Object { description: "Mirage: undefined", fileName: "http://localhost:8100/js/chunk-vendors.js line 2021 > eval", lineNumber: 806,
message: "Mirage: Your app tried to GET 'data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Person</title><path d='M332.64 64.58C313.18 43.57 286 32 256 32c-30.16 0-57.43 11.5-76.8 32.38-19.58 21.11-29.12 49.8-26.88 80.78C156.76 206.28 203.27 256 256 256s99.16-49.71 103.67-110.82c2.27-30.7-7.33-59.33-27.03-80.6zM432 480H80a31 31 0 01-24.2-11.13c-6.5-7.77-9.12-18.38-7.18-29.11C57.06 392.94 83.4 353.61 124.8 326c36.78-24.51 83.37-38 131.2-38s94.42 13.5 131.2 38c41.4 27.6 67.74 66.93 76.18 113.75 1.94 10.73-.68 21.34-7.18 29.11A31 31 0 01432 480z'/></svg>',
but there was no route defined to handle this request.
Define a route for this endpoint in your routes() config.
Did you forget to define a namespace?", name: "Error", number: undefined, stack: "Mirage: MirageError@webpack-internal:///.
试图添加this.passthrough();
和组合它,对任何一个都无济于事。它适用于 API 调用,但不适用于这种特殊情况,我的意思是图标没有被渲染。
我们如何忽略/通过请求data:image/svg+xml;utf8,...
?
解决方案
我遇到了同样的问题。如果您添加此配置以允许加载像 svgs 这样的 base64 图像,则可以解决该错误:
new Server({
routes() {
this.pretender.get('data:image/*', this.pretender.passthrough);
}
});
希望这对你也有效。
推荐阅读
- javascript - 想要将 DIV 下载为 IMAGE,它是画布元素
- python - 使用 openpxl 将 excel 公式应用于列需要很长时间才能执行
- python-3.x - tf.map_fn 中的张量流索引
- javascript - 回调、高阶函数、回调队列有什么区别
- notepad++ - 想要在一定数量的逗号后保留文本(记事本++)
- swift - 为什么我的 UIButton 在 segue 后仍然存在?
- java - 如何从所有按钮打印文本?
- redux - react-redux 应用程序中的操作重复
- asp.net - 42703:列 Extent1.Discriminator 不存在
- c# - 如何编译和运行这个 Github 项目?