在阵营教程中,我期待在example.js
文件
文件从服务器获取评论在这个函数:
var CommentBox = React.createClass({
loadCommentsFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
cache: false,
success: function(data) {
this.setState({data: data});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
// Rest of CommentBox...
但是,在代码中没有require('jquery')
。 React不会将jQuery列为依赖项。当我在反应库中搜索ajax
时,没有任何该函数的声明。
这是$.ajax
功能反应特定的功能?是jQuery以外的东西吗?感谢您的帮助,以便更好地了解React的这部分工作原理!
'$'只是一个变量名,任何人都可以将它定义为任何东西...... – dandavis