Xin chào Tôi chỉ muốn nhận yêu cầu ajax, nhưng vấn đề là jquery không được định nghĩa trong React. Phản ứng phiên bản là 14,0Jquery trong React không được xác định
Thông báo lỗi
Uncaught ReferenceError: $ is not defined
Tôi có hai tập tin
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>
);
}
}
Tôi không thấy bạn định nghĩa jQuery ở bất kỳ đâu trong mã đó. Tại sao bạn nghĩ nó nên hoạt động? – Quentin