Utils
RatioUtils
Before:
import { Utils } from "tuya-panel-kit";
const { convertX } = Utils.RatioUtils;
// Width of a component in the design draft is 13
width = convertX(13); // The final width of the component on the current device
Now:
.content {
width: 26rpx;
}
Since MiniApp natively support the CSS environment, you can use the rpx
unit for adaptation without needing to use convertX
for conversion. For more details, see TYSS Reference - rpx Unit.
ColorUtils
Before:
import { Utils } from "tuya-panel-kit";
const { hsvToRgb } = Utils.ColorUtils;
hsvToRgb(h, s, v);
// Example:
hsvToRgb(0, 1, 1);
Now:
import { utils } from '@ray-js/panel-sdk';
const { hsv2rgb } = utils;
hsv2rgb(h, s, v);
// Example:
hsv2rgb(0, 100, 100);
For more details, see Utility Methods - Color.
TemperatureUtils
Before:
import { Utils } from "tuya-panel-kit";
const { f2c } = Utils.TemperatureUtils;
f2c(fah);
// Example:
f2c(100);
Now:
import { utils } from '@ray-js/panel-sdk';
const { f2c } = utils;
f2c(fah);
// Example:
f2c(100);
For more details, see Utility Methods - Temperature.
JsonUtils
Before:
import { Utils } from "tuya-panel-kit";
const { parseJSON } = Utils.JsonUtils;
parseJSON(str);
//Example:
parseJSON("{a:1, b:2}");
Now:
import { utils } from '@ray-js/panel-sdk';
const { parseJSON } = utils;
parseJSON(str);
//Example:
parseJSON('{a:1, b:2}');
For more details, see Utility Methods - JSON.
CoreUtils
Before:
import { Utils } from "tuya-panel-kit";
const { toFixed } = Utils.CoreUtils;
toFixed(str, num);
// Example:
toFixed("111", 5);
toFixed("3456111", 5);
Now:
import { utils } from '@ray-js/panel-sdk';
const { toFixed } = utils;
toFixed(str, num);
// Example:
toFixed('111', 5);
toFixed('3456111', 5);
For more details, see Utility Methods - Common.
StringUtils
Before:
import { Utils } from "tuya-panel-kit";
const { hexStringToNumber } = Utils.StringUtils;
hexStringToNumber(bits);
// Example:
hexStringToNumber("AD03");
Now:
import { utils } from '@ray-js/panel-sdk';
const { hexStringToNumber } = utils;
hexStringToNumber(bits);
// Example:
hexStringToNumber("AD03");
For more details, see Utility Methods - String.
TimeUtils
Before:
import { Utils } from "tuya-panel-kit";
const { parseSecond } = Utils.TimeUtils;
parseSecond(second, num);
// Example
parseSecond(111);
parseSecond(3333333);
Now:
import { utils } from '@ray-js/panel-sdk';
const { parseSecond } = utils;
parseSecond(second, num);
// Example
parseSecond(111);
parseSecond(3333333);
For more details, see Utility Methods - Time.
NumberUtils
Before:
import { Utils } from "tuya-panel-kit";
const { toFixedString } = Utils.NumberUtils;
toFixedString(value, length);
// Example:
toFixedString(111, 5);
toFixedString(3456111, 5);
Now:
import { utils } from '@ray-js/panel-sdk';
const { toFixedString } = utils;
toFixedString(value, length);
// Example:
toFixedString(111, 5);
toFixedString(3456111, 5);
For more details, see Utility Methods - Number.
Was the content on this page helpful?
yes
Feedback