#工具类
#适配类工具
之前:
import { Utils } from "tuya-panel-kit";
const { convertX } = Utils.RatioUtils;
// 某组件设计稿上宽13
width = convertX(13); // 最后该组件在当前设备的宽度现在:
.content {
width: 26rpx;
}由于小程序天然支持 CSS 环境,可通过 rpx 单位进行适配,无需再使用 convertX 进行转换,详见 TYSS 语法参考-rpx 单位
#颜色转换工具
之前:
import { Utils } from "tuya-panel-kit";
const { hsvToRgb } = Utils.ColorUtils;
hsvToRgb( h, s, v );
// Example:
hsvToRgb(0, 1, 1);现在:
import { utils } from '@ray-js/panel-sdk';
const { hsv2rgb } = utils;
hsv2rgb(h, s, v);
// Example:
hsv2rgb(0, 100, 100);详见 工具方法-颜色
#温度工具
之前:
import { Utils } from "tuya-panel-kit";
const { f2c } = Utils.TemperatureUtils;
f2c(fah);
// Example:
f2c(100);现在:
import { utils } from '@ray-js/panel-sdk';
const { f2c } = utils;
f2c(fah);
// Example:
f2c(100);详见 工具方法-温度
#JSON 解析工具
之前:
import { Utils } from "tuya-panel-kit";
const { parseJSON } = Utils.JsonUtils;
parseJSON(str);
//Example:
parseJSON("{a:1, b:2}"); 现在:
import { utils } from '@ray-js/panel-sdk';
const { parseJSON } = utils;
parseJSON(str);
//Example:
parseJSON('{a:1, b:2}');详见 工具方法-JSON
#核心工具
之前:
import { Utils } from "tuya-panel-kit";
const { toFixed } = Utils.CoreUtils;
toFixed(str, num);
// Example:
toFixed("111", 5);
toFixed("3456111", 5);现在:
import { utils } from '@ray-js/panel-sdk';
const { toFixed } = utils;
toFixed(str, num);
// Example:
toFixed('111', 5);
toFixed('3456111', 5);详见 工具方法-通用
#字符串工具
之前:
import { Utils } from "tuya-panel-kit";
const { hexStringToNumber } = Utils.StringUtils;
hexStringToNumber(bits);
// Example:
hexStringToNumber("AD03");现在:
import { utils } from '@ray-js/panel-sdk';
const { hexStringToNumber } = utils;
hexStringToNumber(bits);
// Example:
hexStringToNumber("AD03");详见 工具方法-字符串
#时间工具
之前:
import { Utils } from "tuya-panel-kit";
const { parseSecond } = Utils.TimeUtils;
parseSecond(second, num);
// Example
parseSecond(111);
parseSecond(3333333);现在:
import { utils } from '@ray-js/panel-sdk';
const { parseSecond } = utils;
parseSecond(second, num);
// Example
parseSecond(111);
parseSecond(3333333);详见 工具方法-时间
#数值工具
之前:
import { Utils } from "tuya-panel-kit";
const { toFixedString } = Utils.NumberUtils;
toFixedString(value, length);
// Example:
toFixedString(111, 5);
toFixedString(3456111, 5);现在:
import { utils } from '@ray-js/panel-sdk';
const { toFixedString } = utils;
toFixedString(value, length);
// Example:
toFixedString(111, 5);
toFixedString(3456111, 5);详见 工具方法-数值