更新记录
1.0.0(2025-03-28)
下载此版本
重构代码解决页面内容组件切换后,内容组件该子组件的未知报错,已增加扩展参数。
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
× |
× |
√ |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
简介:
- 已测试适用于Vue2、Vue3版本的uniapp微信小程序。
- 因官方未知兼容问题,所以使用type2D和Vue2写法才可实现。
- 原理是使用原图片信息绘制到canvas后分析和修改像素数据并输出临时图。
- 组件简单易用,可参考以下例子,有问题请评论区友好提问,感谢!
参数说明:
参数名 |
参数类型 |
参数默认值 |
参数说明 |
iconUrl |
String |
|
img网络地址,需要支持uni.getImageInfo API的img类型 |
targetHex |
String |
|
十六进制0xFF0060AA |
targetHex1 |
String |
|
十六进制#000000 |
rgba |
String |
|
rgba(0,0,0,1) |
cssWidth |
Number |
200 |
px |
cssHeight |
Number |
200 |
px |
canvasName |
String |
'myCanvas' + '-' + (new Date().getTime()) |
canvas的id唯一标识,不能重复,用于页面存在多个组件的场景 |
customStyle |
Object |
|
处理后的图片的自定义样式 |
isShow |
Boolean |
|
v-show的显示和隐藏 |
基本使用:
<template>
<view class="content">
<text class="title">修改前</text>
<image class="logo" :src="imgUrl" />
<text class="title">修改后</text>
<ColorIcon :iconUrl="imgUrl" targetHex="0xFF0060AA" :cssWidth="100" :cssHeight="100" />
<ColorIcon :iconUrl="imgUrl" targetHex1="#000000" :cssWidth="100" :cssHeight="100" />
<ColorIcon :iconUrl="imgUrl" rgba="rgba(252,25,68,1)" :cssWidth="100" :cssHeight="100" />
</view>
</template>
<script>
import ColorIcon from '@/components/ColorIcon/ColorIcon.vue'
export default {
data() {
return {
imgUrl:''//网络地址
}
},
components: {
ColorIcon
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 100rpx;
height: 100vh;
background: springgreen;
box-sizing: border-box;
}
.logo {
height: 100px;
width: 100px;
margin-top: 20rpx;
}
.title {
font-size: 36rpx;
color: #8f8f94;
margin: 50rpx 0 20rpx 0;
}
</style>