求助:ios系统不显示svg的linearGradient

react项目webpack打包

svg源文件

<svg
  viewBox="0 0 10 10"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <linearGradient id="myGradient" gradientTransform="rotate(90)">
      <stop offset="5%" stop-color="gold" />
      <stop offset="95%" stop-color="red" />
    </linearGradient>
  </defs>

  <!-- using my linear gradient -->
  <circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>

使用webpack-svgstore-plugin将svg文件生成了精灵图

处理代码

import path from 'path';
import fs from 'fs';
import SvgStorePlugin from 'webpack-svgstore-plugin';
import sha256 from 'crypto-js/sha256';
const svgSpritesHelper = ({
  inputPaths, baseOutputPath, srpiteOutputPath, assetsJsonPath,
}) => {
  const spriteBuilders = [];
  const svgManifest = {};

  inputPaths.map((input) => {
    // Group SVGs by folders
    getSprites(input).map((folder) => {
    	.........
    	.........

      // Store the SVGs into one chunk
      spriteBuilders.push(new SvgStorePlugin(path.join(input, `${folder}/*.svg`), srpiteOutputPath, {
        name: `${folder}-${hash}.svg`,
        chunk: 'svgs',
        prefix: '',
      }));
      return true;
    });

    return true;
  });

  // Save manifest
  saveHash(svgManifest, assetsJsonPath);

  // Hand over to the Webpack
  return spriteBuilders;
};

export default svgSpritesHelper;

生成的精灵图,这里面有linearGradient

...</style><mask id="icon-fancy-loading-a"> <rect x="5%" y="5%" width="90%" height="90%" fill="#fff"></rect><text dy=".01em" x="50%" y="50%" text-anchor="middle" dominant-baseline="central" font-weight="900" font-size="20" font-family="arial"><![CDATA[Loading]]></text></mask><linearGradient x1="0%" y1="0%" y2="0%" id="icon-vip-medium"> <stop stop-color="#FFE899" offset="0%"></stop><stop stop-color="#FFC600" offset="100%"></stop></linearGradient><linearGradient x1="0%" y1="0%" y2="0%" id="icon-vip-round-a"> <stop stop-color="#FFE899" offset="0%"></stop><stop stop-color="#FFC600" offset="100%"></stop></linearGradient><linearGradient x1="0%" y1="0%" y2="0%" id="icon-vip-small-a"> <stop stop-color="#FFE899" offset="0%"></stop><stop stop-color="#FFC600" offset="100%"></stop></linearGradient><style id="icon-loading-icon-id"> </style><style id="icon-send-out-icon-id"> </style><style id="icon-transit-icon-id"> </style><style id="icon-triangle-arrow-icon-id"> </style>...

生成的精灵图在苹果系统不显示渐变,或者渐变颜色为黑色,但在Windows和安卓系统下正常显示

如果直接在js中使用svg源文件可以正常显示

我猜测是webpack-svgstore-plugin造成的问题?
有大佬告诉我下解决思路吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值