ionic-framework - Miragejs:无法加载 ionic 图标 - data:image/svg+xml

标签 ionic-framework mocking miragejs

浏览器控制台出现以下错误,图标未呈现。

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);
  }
});

希望这对你也有用。

关于ionic-framework - Miragejs:无法加载 ionic 图标 - data:image/svg+xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66639978/

相关文章:

javascript - ngFor 内部 ngFor 导致错误

css - 在 ionic slider 中从 sd 卡设置 div 背景图像

java - Mockito - 仅模拟一个方法

javascript - 将所有 MirageJS id 转换为整数

miragejs - 有没有办法在不侧载或嵌入数据的情况下显示相关模型 ID

firebase - 将 Azure 通知中心与 Firebase 和 iOS(而非 APNS)结合使用

javascript - 如何使用 Angular Material 日历

javascript - 在对 AngularJS Controller 进行单元测试时如何模拟网络延迟?

c# - 如何使用 Moq 模拟 X509Certificate2?