如何在 Django 读取的单独静态 js 文件中获取反应组件?最少要安装什么才能使其工作?

How to get react components in a separate static js file read by Django? What is the least to be installed to make it work?

需要进行哪些修改? And/or 至少需要安装什么才能让它工作?

首先,在静态reactclasses.js文件中 该文件只包含这个。 (还有什么需要补充的吗?)

class Login extends React.Component {
    render() {
        return (
            <div id="login">
                <form action="/login" method="POST">
                    <input type="text" name="username" placeholder="Username" required/>
                    <input type="password" name="password" placeholder="Password" required/>
                    <input type="submit" value="Submit"/>
                </form>
            </div>
        );
    }
}

在 html 文件中

<!--- in the head tag --->
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script src="{% static 'reactclasses.js' %}" type="text/babel"></script>

<!--- in a script tag with type=text/babel in the body tag -->
ReactDOM.render(<login />, document.querySelector("thediv"));

the console errors image

很久以前就想出来了..

下面是详细的操作方法
https://dev.to/zachtylr21/how-to-serve-a-react-single-page-app-with-django-1a1l

并且