mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
14 lines
499 B
TypeScript
14 lines
499 B
TypeScript
/**
|
|
* Stringify a property value for use in Vue templates
|
|
*
|
|
* 将属性值字符串化为可在 Vue 模板中使用的格式
|
|
*
|
|
* @param data - Data to stringify / 要字符串化的数据
|
|
* @returns Stringified data with single quotes escaped / 字符串化后的数据,单引号已转义
|
|
*/
|
|
export function stringifyProp(data: unknown): string {
|
|
// Single quote will break @vue/compiler-sfc
|
|
// 单引号会破坏 @vue/compiler-sfc
|
|
return JSON.stringify(data).replace(/'/g, ''')
|
|
}
|