更新记录
                                                                                                    
                                                    
                                                        0.4.2(2025-09-26)
                                                                                                                    
                                                                下载此版本
                                                            
                                                        
                                                    
                                                    
                                                                                                    
                                                    
                                                        0.4.1(2025-06-13)
                                                                                                                    
                                                                下载此版本
                                                            
                                                        
                                                    
                                                    
                                                                                                    
                                                    
                                                        0.4.0(2025-06-04)
                                                                                                                    
                                                                下载此版本
                                                            
                                                        
                                                    
                                                    
                                                                                                                                                    查看更多
                                                                                                
                                            
                                                                                                                                                        平台兼容性
                                                                                                                                                                                                                                                                                                                                uni-app(4.55)
                                                                                                                                                                                                                                    
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 | 
| √ | √ | √ | √ | √ | - | 5.0 | √ | √ | 
                                                                                                                                                            
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 | 
| √ | √ | √ | √ | - | - | - | - | - | - | - | 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                uni-app x(4.55)
                                                                                                                                                                                                                                    
| Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 | 
| √ | √ | 5.0 | √ | √ | √ | 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                            lime-shared 工具库
文档
🚀 shared【站点1】
🌍 shared【站点2】
🔥 shared【站点3】
安装
在插件市场导入即可
使用
按需引入只会引入相关的方法,不要看着 插件函数列表多 而占空间,只要不引用不会被打包
import {getRect} from '@/uni_modules/lime-shared/getRect'
目录
Utils
getRect 
// 组件内需要传入上下文
// 如果是nvue 则需要在节点上加与id或class同名的ref
getRect('#id',this).then(res => {})
兼容性
addUnit 
addUnit(10)
// 10px
兼容性
unitConvert 
- 将带有rpx|px的字符转成number,若本身是number则直接返回
unitConvert('10rpx') 
// 5 设备不同 返回的值也不同
unitConvert('10px') 
// 10
unitConvert(10) 
// 10
兼容性
canIUseCanvas2d 
canIUseCanvas2d()
// 若支持返回 true 否则 false
兼容性
getCurrentPage 
const page = getCurrentPage()
兼容性
base64ToPath 
base64ToPath(`xxxxx`).then(res => {})
兼容性
pathToBase64 
pathToBase64(`xxxxx/xxx.png`).then(res => {})
兼容性
sleep 
- 睡眠,让 async 内部程序等待一定时间后再执行
async next () => {
    await sleep(300)
    console.log('limeui');
}
兼容性
throttle 
throttle((nama) => {console.log(nama)}, 200)('limeui');
兼容性
debounce 
debounce((nama) => {console.log(nama)}, 200)('limeui');
兼容性
random 
random(1, 5);
兼容性
range 
range(0, 5)
// [0,1,2,3,4,5]
兼容性
clamp 
- 夹在min和max之间的数值,如小于min,返回min, 如大于max,返回max,否侧原值返回
clamp(0, 10, -1)
// 0
clamp(0, 10, 11)
// 10
clamp(0, 10, 9)
// 9
兼容性
floatAdd 
floatAdd(0.1, 0.2) // 0.3
兼容性
fillZero 
fillZero(9);
// 09
兼容性
exif 
uni.chooseImage({
    count: 1, //最多可以选择的图片张数
    sizeType: "original",
    success: (res) => {
        exif.getData(res.tempFiles[0], function() {
            let tagj = exif.getTag(this, "GPSLongitude");
            let Orientation = exif.getTag(this, 'Orientation');  
            console.log(tagj, Orientation)
        })
    }
})
兼容性
selectComponent 
- 获取页面或当前实例的指定组件,会在页面或实例向所有的节点查找(包括子组件或子子组件)
- 仅vue3,vue2没有测试过
// 当前页面
const page = getCurrentPage()
selectComponent('.custom', {context: page}).then(res => {
})
兼容性
createAnimation 
- 创建动画,与uni.createAnimation使用方法一致,只为了抹平nvue
<view ref="ball" :animation="animationData"></view>
const ball = ref(null)
const animation = createAnimation({
  transformOrigin: "50% 50%",
  duration: 1000,
  timingFunction: "ease",
  delay: 0
})
animation.scale(2,2).rotate(45).step()
// nvue 无导出数据,这样写只为了平台一致,
// nvue 需要把 ref 传入,其它平台不需要
const animationData = animation.export(ball.value)
兼容性
兼容性
camelCase 
- 将字符串转换为 camelCase 或 PascalCase 风格的命名约定
camelCase("hello world") // helloWorld
camelCase("hello world", true) // HelloWorld
兼容性
kebabCase 
kebabCase("helloWorld") // hello-world
kebabCase("hello world_example") // hello-world-example
kebabCase("helloWorld", "_") // hello_world
兼容性
closest 
closest([1, 3, 5, 7, 9], 6) // 5
兼容性
shuffle 
shuffle([1, 3, 5, 7, 9]) 
兼容性
merge 
const original = { color: 'red' };
const merged = merge({ ...original }, { color: 'blue', size: 'M' });
console.log('original', original);    // 输出: { color: 'red' } (保持不变)
console.log('merged', merged);      // 输出: { color: 'red', size: 'M' }
type ColorType = {
    color?: string,
    size?: string,
}
const merged2 = merge({ color: 'red' } as ColorType, { color: 'blue', size: 'M' } as ColorType);
console.log('merged2', merged2)
兼容性
isBase64 
isBase64('xxxxx')
兼容性
isNumber 
isNumber('0') // false
isNumber(0) // true
兼容性
isNumeric 
isNumeric('0') // true
isNumeric(0) // true
兼容性
isString 
isString('0') // true
isString(0) // false
兼容性
isIP 
- 检查一个值是否为IP地址格式,可以检测ipv4,ipv6
console.log(isIP('192.168.1.1'));             // true
console.log(isIP('2001:0db8:85a3:0000:0000:8a2e:0370:7334')); // true
console.log(isIP('192.168.1.1', 4));             // true
console.log(isIP('255.255.255.255', { version: 4 })); // true
// 标准IPv6格式
console.log(isIP('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 6)); // true
console.log(isIP('fe80::1%eth0', { version: 6 }));               // true(带区域标识)
兼容性
composition-api 
//使用
import {computed, onMounted, watch, reactive} from '@/uni_modules/lime-shared/vue'
兼容性