我的代码中有1行有错误,但我不知道如何解决。请帮助我,我只是一个初学者。
<SafeAreaView style={styles.root}>
<View style={styles.container}>
<Svg {...{width,height}}>
<Path d={line} fill="transparent" stroke="#367BE2" strokeWidth={5} />
<Path d={'${line} L ${width} ${height} L 0 ${height}'} fill="red"/>
</Svg>
</View>
</SafeAreaView>
错误在这一行:
路径d = {'$ {line} L $ {width} $ {height} L 0 $ {height}'} fill =“ red”
我希望图表中会有红色背景作为输出,但是会导致错误
答案 0 :(得分:0)
我认为您的错误是在此行上使用单引号
<Path d={'${line} L ${width} ${height} L 0 ${height}'} fill="red"/>
尝试使用反引号``而不是单引号''
来修改字符串