ReactDOM 不是使用 react/17.0.1/umd/react.development.js 定义的
ReactDOM is not defined by using react/17.0.1/umd/react.development.js
我正在通过 React Quickly, Azat Mardan 学习 React v15.5.4. All examples contain two files react.js
and react-dom.js
, for example hello-js-world-jsx. I would like to use the latest React version that is v17.0.1 而这个版本没有这些文件。
我应该使用 v17.0.1 中的哪些文件来使 hello-js-world-jsx 示例正常工作?
第二个问题是v17.0.1没有ReactDOM.render。我得到类似
的东西
Uncaught ReferenceError: ReactDOM is not defined
请注意,我不想只使用 npm
文件的模块。
感谢您的支持!
根据官方文档:
您需要开发模式的链接:
<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
https://reactjs.org/docs/cdn-links.html
为了正确地将道具 'frameworkName' 重命名为小写 'frameworkname'
class HelloWorld extends React.Component {
render() {
return React.createElement(
'h1',
this.props,
'Hello ',
this.props.frameworkname,
' world!!!'
);
}
}
ReactDOM.render(React.createElement(
'div',
null,
React.createElement(HelloWorld, {
id: 'ember',
frameworkname: 'Ember.js',
title: 'A framework for creating ambitious web applications.' }),
React.createElement(HelloWorld, {
id: 'backbone',
frameworkname: 'Backbone.js',
title: 'Backbone.js gives structure to web applications...' }),
React.createElement(HelloWorld, {
id: 'angular',
frameworkname: 'Angular.js',
title: 'Superheroic JavaScript MVW Framework' })
), document.getElementById('content'));
我正在通过 React Quickly, Azat Mardan 学习 React v15.5.4. All examples contain two files react.js
and react-dom.js
, for example hello-js-world-jsx. I would like to use the latest React version that is v17.0.1 而这个版本没有这些文件。
我应该使用 v17.0.1 中的哪些文件来使 hello-js-world-jsx 示例正常工作?
第二个问题是v17.0.1没有ReactDOM.render。我得到类似
的东西
Uncaught ReferenceError: ReactDOM is not defined
请注意,我不想只使用 npm
文件的模块。
感谢您的支持!
根据官方文档: 您需要开发模式的链接:
<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
https://reactjs.org/docs/cdn-links.html
为了正确地将道具 'frameworkName' 重命名为小写 'frameworkname'
class HelloWorld extends React.Component {
render() {
return React.createElement(
'h1',
this.props,
'Hello ',
this.props.frameworkname,
' world!!!'
);
}
}
ReactDOM.render(React.createElement(
'div',
null,
React.createElement(HelloWorld, {
id: 'ember',
frameworkname: 'Ember.js',
title: 'A framework for creating ambitious web applications.' }),
React.createElement(HelloWorld, {
id: 'backbone',
frameworkname: 'Backbone.js',
title: 'Backbone.js gives structure to web applications...' }),
React.createElement(HelloWorld, {
id: 'angular',
frameworkname: 'Angular.js',
title: 'Superheroic JavaScript MVW Framework' })
), document.getElementById('content'));