意外的令牌错误:未加载React js页面

时间:2018-12-09 23:36:26

标签: javascript reactjs react-native

我正在使用以下线程在没有服务器的浏览器上运行react js,但它始终抛出以下错误。 index.html中的所有链接似乎都很好用。

Run simple react js in browser locally

https://www.quora.com/How-do-you-run-react-js-code-on-your-local

Unexpected token (1:1)
> 1 | <!DOCTYPE html>
    |  ^
  2 | <html>
  3 | <head>
  4 |     <meta charset="UTF-8" />
    at Parser.pp.raise (browser.min.js:41)
    at Parser.pp.unexpected (browser.min.js:42)
    at Parser.pp.jsxParseIdentifier (browser.min.js:43)
    at Parser.pp.jsxParseNamespacedName (browser.min.js:43)
    at Parser.pp.jsxParseElementName (browser.min.js:43)
    at Parser.pp.jsxParseOpeningElementAt (browser.min.js:43)
    at Parser.pp.jsxParseElementAt (browser.min.js:43)
    at Parser.pp.jsxParseElement (browser.min.js:43)
    at Parser.parseExprAtom (browser.min.js:43)
    at Parser.pp.parseExprSubscripts (browser.min.js:40)
    at Parser.pp.parseMaybeUnary (browser.min.js:40)
    at Parser.pp.parseExprOps (browser.min.js:40)
    at Parser.pp.parseMaybeConditional (browser.min.js:40)
    at Parser.pp.parseMaybeAssign (browser.min.js:40)
    at Parser.pp.parseExpression (browser.min.js:40)
    at Parser.pp.parseStatement (browser.min.js:41)
    at Parser.parseStatement (browser.min.js:42)
    at Parser.pp.parseTopLevel (browser.min.js:41)
    at Parser.parse (browser.min.js:41)
    at Object.parse (browser.min.js:40)
    at Object.exports.default (browser.min.js:7)
    at File.parse (browser.min.js:7)
    at File.parseCode (browser.min.js:7)
    at browser.min.js:10
    at File.wrap (browser.min.js:7)
    at Pipeline.transform (browser.min.js:10)
    at Function.transform.run (browser.min.js:4)
    at exec (browser.min.js:4)
    at browser.min.js:4
    at XMLHttpRequest.xhr.onreadystatechange (browser.min.js:4)
pp.raise @ browser.min.js:41
pp.unexpected @ browser.min.js:42
pp.jsxParseIdentifier @ browser.min.js:43
pp.jsxParseNamespacedName @ browser.min.js:43
pp.jsxParseElementName @ browser.min.js:43
pp.jsxParseOpeningElementAt @ browser.min.js:43
pp.jsxParseElementAt @ browser.min.js:43
pp.jsxParseElement @ browser.min.js:43
(anonymous) @ browser.min.js:43
pp.parseExprSubscripts @ browser.min.js:40
pp.parseMaybeUnary @ browser.min.js:40
pp.parseExprOps @ browser.min.js:40
pp.parseMaybeConditional @ browser.min.js:40
pp.parseMaybeAssign @ browser.min.js:40
pp.parseExpression @ browser.min.js:40
pp.parseStatement @ browser.min.js:41
(anonymous) @ browser.min.js:42
pp.parseTopLevel @ browser.min.js:41
parse @ browser.min.js:41
parse @ browser.min.js:40
exports.default @ browser.min.js:7
parse @ browser.min.js:7
parseCode @ browser.min.js:7
(anonymous) @ browser.min.js:10
wrap @ browser.min.js:7
transform @ browser.min.js:10
transform.run @ browser.min.js:4
exec @ browser.min.js:4
(anonymous) @ browser.min.js:4
xhr.onreadystatechange @ browser.min.js:4
XMLHttpRequest.send (async)
transform.load @ browser.min.js:4
run @ browser.min.js:4
runScripts @ browser.min.js:4

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
    <!-- <script src="build/react.js"></script> -->
    <!-- <script src="build/react-dom.js"></script> -->
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <!-- import react.js -->

    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"> </script>
    <!-- import react-dom.js -->

    <script type="text/babel" src="../myproject.js"></script>
</head>
<body>
<div id="container"></div>

</body>
</html>

0 个答案:

没有答案