JavaScript动态变量名称根据另一个变量

时间:2016-06-08 08:15:18

标签: javascript reactjs

sum=0
while read line
                do
                if [ "$line" = "---------------" ]; then
                        echo $sum
                        sum=0
                else sum=`echo $line $sum | awk '{print $1 + $2}'`
                fi
done < input_file.txt

我如何才能获得来自变量onClick={ this.props.remove(this.props. + this.props.title) } 的{​​{1}} 这个例子不起作用

2 个答案:

答案 0 :(得分:2)

使用bracket notation

onClick={() => this.props.remove(this.props[this.props.title])}

答案 1 :(得分:1)

您可以使用bracket notation

onClick={ () => this.props.remove(this.props[this.props.title]) }
相关问题