0
我是非常新的反应,当涉及到将数据从一个方法传递到另一个方法时,我遇到了问题。 这里是我的反应语法:TypeError:无法读取未定义的属性'信息'
var url = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1"
class App extends React.Component{
info(val){
console.log(val)
}
request(){
axios.get(url)
.then(function (response) {
this.info(response)
console.log(response.data);
})
}
render() {
return(
<div>
<h1>axios</h1>
{this.request()}
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById("target"))
我的目标是从request
方法传递响应数据info
方法。但是,我得到的错误说,"TypeError: Cannot read property 'info' of undefined"
你能帮我找出我失踪的东西吗?
绑定问题,检查重复的问题 –