您会收到此错误,因为JavaScript表达式中的scale
是undefined
。
您必须在javascript expression
中将CSS作为字符串编写。
例如这样的:
transform: ${props => props.display === 'none' ? `scale(0.7)` : `scale(1,1)`};
我在代码沙箱中为您提供了一个简单的代码:
https://codesandbox.io/s/musing-dirac-tb08v
更多资源:
https://www.styled-components.com/docs/basics#adapting-based-on-props
,
与此问题相关,在像这样的规模内使用道具。
m = df.groupby(['id','y',df['y'].cumsum()]).cumcount() + 1 ########## setup you base getting cumcount
df['num_month'] = np.where((m == 1) & (m.shift() > 1),m.shift() + 1,m).astype(int) # extend cumcount one further row per group for first line of code
s1 = df.groupby('id').transform('idxmin').iloc[:,0] ############## get index location of first value per group and return as series with same length
s2 = df.groupby(['id',(df['y'] > 0).cumsum()]).transform('idxmin').iloc[:,0] ######### get index location of first non-zero value per group and return as series with same length
df['num_month'] = df['num_month'].mask((s1 == s2) | (s1 == s2.shift()),-1) ########### using s1 and s2 conditions,update the necessary rows to -1
df
Out[1]:
id year month y sinx num_month
0 1 2019 1 0 1 -1
1 1 2019 2 0 2 -1
2 1 2019 3 1 3 -1
3 1 2019 4 0 4 1
4 1 2019 5 0 5 2
5 1 2019 6 0 6 3
6 1 2019 7 0 7 4
7 1 2019 8 2 8 5
8 1 2019 9 0 9 1
9 1 2019 10 0 10 2
10 1 2019 11 0 11 3
11 1 2019 12 0 11 4
12 1 2020 1 0 12 5
13 1 2020 2 0 13 6
14 1 2020 3 2 14 7
15 1 2020 4 0 15 1
16 2 2019 1 0 1 -1
17 2 2019 2 0 2 -1
18 2 2019 3 1 3 -1
19 2 2019 4 0 4 1
本文链接:https://www.f2er.com/3132115.html