import{ax as i,z as a,A as t,b2 as l}from"./chunks/framework.DkLJC2NO.js";const g=JSON.parse('{"title":"工具函数","description":"","frontmatter":{},"headers":[],"relativePath":"runtime-api/core/utils.md","filePath":"runtime-api/core/utils.md"}'),n={name:"runtime-api/core/utils.md"};function e(p,s,h,r,k,o){return t(),a("div",null,[...s[0]||(s[0]=[l(`
@tmagic/core 导出的工具函数。
参数:
{string} style CSS 样式字符串返回:
{object} 样式对象详情:
将 CSS 样式字符串转换为对象格式。
示例:
import { style2Obj } from '@tmagic/core';
const styleObj = style2Obj('width: 100px; height: 200px;');
console.log(styleObj); // { width: '100px', height: '200px' }参数:
{string} value 背景图片 URL返回:
{string} 完整的 CSS 背景图片值详情:
填充背景图片 URL 为完整的 CSS 格式。
示例:
import { fillBackgroundImage } from '@tmagic/core';
const bg = fillBackgroundImage('https://example.com/image.png');
console.log(bg); // 'url(https://example.com/image.png)'参数:
{object} value transform 配置{JsEngine} jsEngine JS 引擎类型返回:
{string} CSS transform 字符串详情:
根据配置生成 CSS transform 字符串,会根据 JS 引擎类型进行适配。
参数:
{object} style 样式对象{JsEngine} jsEngine JS 引擎类型返回:
{object} 转换后的样式对象详情:
转换样式对象,将数值转换为 rem 单位(移动端适配)。
示例:
import { transformStyle } from '@tmagic/core';
const style = transformStyle({ width: 100, height: 200 }, 'browser');
console.log(style); // { width: '1rem', height: '2rem' }值: 'magic:common:events:'
详情:
通用事件前缀。
值: 'magic:common:actions:'
详情:
通用方法前缀。
示例:
import { COMMON_EVENT_PREFIX, COMMON_METHOD_PREFIX } from '@tmagic/core';
const eventKey = \`\${COMMON_EVENT_PREFIX}click\`;
const methodKey = \`\${COMMON_METHOD_PREFIX}show\`;