[英]console.log is returning the function instead of returning interger
class TransitionComp extends Component{
Duration = ()=>{
return Math.floor(Math.random() * Math.floor(3000))
}
render(){
console.log(this.Duration)
return(
)
}
}
控制台正在返回
ƒ () {
return Math.floor(Math.random() * Math.floor(3000));
}
而不是整数。 如果我不使用“ this”,则持续时间将变得不确定。
调用该函数的正确方法是:
console.log(this.Duration());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.