只是尝试使用没有webpack和npm的JSX做简单的例子.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.1/babel.min.js"></script>
<script src="http://unpkg.com/mithril/mithril.js"></script>
</head>
<body>
<script type="text/babel">
var MyComponent = {
view: function() {
return (
<main>
<h1>Hello world</h1>
</main>
)
}
}
m.render(document.body, <MyComponent />)
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但得到React错误:
Uncaught ReferenceError: React is not defined
Run Code Online (Sandbox Code Playgroud)
我很困惑,为什么React与此有任何关系.
mithril.js ×1