解析字符串css样式
const themeColor = `
--btn-radius: 44rpx;
--theme-color: #41c2a6;
--theme-color-op: rgba(55, 176, 172, 0.3);
`
/**
* 根据key获取value
* @param {string} themeColor
* @param {string} key
* @returns value
*/
const getThemeColor = (themeColor, key) => {
const reg = new RegExp(`${
key}:(.+?)\;`);
const themeColorStr = themeColor.match(reg)[0]
const newStr = themeColorStr.slice(key.length + 1, themeColorStr.length - 1)
return newStr.trim()
<