IconPark icon indicating copy to clipboard operation
IconPark copied to clipboard

iconpark-icon(web-component)方式在andriod设备的适配问题

Open sphenginx opened this issue 2 years ago • 1 comments

hi, 我在使用 <iconpark-icon> 组件时发现了个问题:

组件的样式(class=‘icon-normal’)中设置了 background-color: #fff,图标默认的 stroke 颜色也是 #fff, 但是在 组件传入 stroke=‘#333’ 并且 fill=‘#333’ 时, 在 andriod 设备上会先渲染默认的白色, 再渲染 #333 的颜色… …

const {status} = props
const [iconStroke,  setIconStroke] = useState();

useEffect(() =>{
   switch(status) {
      case 'normal':
        setIconStroke('#333')
        break;
      default:
        break;
   }
}, [status])

渲染时

<iconpark-icon
  name={imgName}
  width="100%"
  height="100%"
  class={`icon-${status}`}
  stroke={iconStroke}
  fill={iconStroke}
  />test</iconpark-icon>

sphenginx avatar Aug 08 '22 08:08 sphenginx

之前考虑是 useEffect执行时机的问题, 但是弃用了 useEffect,仍然有这个问题:

let iconStroke = '#333'
	let arrowFill = '#999'
	if (status === 'selected') {
		iconStroke = '#fff'
		arrowFill = '#2283e2'
	}

sphenginx avatar Aug 09 '22 03:08 sphenginx