嗨,我只是想接收ajax請求,但問題是jQuery沒有在React中定義。反應過來的版本是14.0React中的Jquery未定義
錯誤消息
Uncaught ReferenceError: $ is not defined
我有兩個文件
index.js
import React from 'react';
import { render } from 'react-dom';
import App from './containers/App';
const root = document.getElementById('root');
render(
<App source='https://api.github.com/users/octocat/gists' />,
root
);
app.js
import React, { Component } from 'react';
export default class App extends Component {
componentDidMount() {
const { source } = this.props;
console.log($); // throws error
}
render() {
return (
<h1>Hey there.</h1>
);
}
}
我看不到您在該代碼中的任何位置定義jQuery。你爲什麼認爲它應該工作? – Quentin