javascript - 如何在没有 SVG 代码的情况下将 SVG 颜色作为附加图像进行操作?
问题描述
根据某些条件,我将获得不同的 SVG。所以,我无法获取 SVG 代码,服务器携带 svg 文件。
那么有什么方法可以实现这一点吗?我需要动态更改颜色,无论我得到什么 svg。这是我的代码
<svg >
<img src="rect.svg"width= "150px" height="150px">
</svg>
解决方案
fill: currentColor;
或者
fill: red; // Any other color
推荐阅读
- mysql - 连接同一张表时,如何将连接的数据放在单独的行而不是单独的列中?
- javascript - HTML 表格中显示多个 JSON 提要
- ios - 是否有苹果 API 可以在应用程序上取消关联 Apple ID?
- python - 如何以用户输入“XXX”结束?
- django - 如何使用 django 模型在 mongodb 中制作嵌入式文档?
- php - 如何在 laravel 8 中使用旧标签和新标签更新帖子?
- r - 改变限制三次样条曲线的参考值
- flutter - Flutter DIO 库 XMLHttpRequest 报错 Web
- python - 在 Pyplot 中使子图变大
- typescript - Typescript 接口数组必须实现一个基本接口