简体   繁体   English

当我尝试向我的网站添加反应时没有任何反应,看起来浏览器没有检测到文件

[英]Nothing happens when I try and add react to my site, it doesn't look like the browser is detecting the file

I am trying to add react to my site but nothing is happening.我正在尝试向我的网站添加反应,但没有任何反应。 I can't see where I am going wrong.我看不出哪里出错了。

The site is built using HTML and I am adding react to it该站点是使用 HTML 构建的,我正在添加对它的反应

Here is my code:这是我的代码:

<div id="goalsReact"></div>

<!-- Load React. -->
<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<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 type="text/babel" src="js/goals.js"></script>
<script src="js/scripts.js"></script>
<script type="text/jsx">
    ReactDOM.render(
        <Goals />,
        document.getElementById('goalsReact');
    );
</script>

In order to use JSX in your HTML file, like you're doing, you would need to add babel to transpile your code into regular JavaScript: https://reactjs.org/docs/add-react-to-a-website.html#quickly-try-jsx为了在您的 HTML 文件中使用 JSX,就像您正在做的那样,您需要添加 babel 以将您的代码转换为常规 JavaScript: Z5E056C500A1C4B6A7110B50D807BADE-react-Z: html#quickly-try-jsx

Here's a demo: https://codesandbox.io/s/stack-overflow-jsx-in-html-p7nnk?file=/index.html这是一个演示: https://codesandbox.io/s/stack-overflow-jsx-in-html-p7nnk?file=/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我在React / Firebase App中单击我的按钮时没有任何反应 - Nothing happens when I click my button in React/Firebase App 当我尝试使用此XMLHttpRequest对象加​​载此xml文件时,什么也没有发生 - when i try to load this xml file with this XMLHttpRequest object just nothing happens 当我尝试使用 client.user.setAvatar() 时,没有任何反应 - When I try to use client.user.setAvatar(), nothing happens 当我尝试将数据从一个组件传递到另一个组件时,浏览器不显示任何内容-React - Browser displays nothing when I try to pass the data from one component to another -React HTML onclick不会触发我的功能,什么也没发生 - HTML onclick doesn't trigger my function, just nothing happens 我的@media CSS 选择器不起作用,当我更改屏幕尺寸时,没有任何反应 - my @media CSS selector isn't working, When I change the screen size, nothing happens 我的网站在不同分辨率下看起来不正确 - My site doesn't look correct on different resolutions 单击我的Chrome扩展程序后,什么都没有发生 - Nothing happens when I click my chrome extension 当我尝试为待办事项列表应用创建LI元素时,浏览器屏幕上没有任何显示 - When I try to create an LI element for my todo-list app, nothing shows up on my browser screen 如果浏览器不支持我的角度站点,则重定向站点 - redirect site if browser doesn't support my angular site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM