className react.js内部的调用函数 [英] call function inside of className react.js
本文介绍了className react.js内部的调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在此示例中为 className
调用 getClass
的函数?我写出来的方式似乎不叫 getClass
.
How do I call the function for getClass
for the className
inside this example? The way I have it written out does not seem to call getClass
.
var CreateList = React.createClass({
getClass: function() {
//some code to return className
},
render: function() {
return(
<div className{this.getClass}>Example</div>
);
}
});
推荐答案
您正在引用 getClass()
函数的实例,而不是调用该函数.尝试像这样调整它:
You're referencing the instance of the getClass()
function as opposed to calling the function. Try tweaking it like so:
render: function() {
return(
<div className={this.getClass()}>Example</div>
);
}
这篇关于className react.js内部的调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文