1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| /**
| * 提取css中带有calc函数的表达式的参数部分
| * @param {String} str css中带有calc函数的表达式
| */
| function unCalc(str) {
| if (str.startsWith('calc(')) {
| let _str = str.replace('calc(', '')
| _str = _str.replace(/\)/g, (match, offset, string) => {
| if (offset === string.lastIndexOf(match)) {
| return ''
| } else {
| return match
| }
| })
| return _str
| } else {
| return str
| }
| }
|
| export { unCalc }
|
|