JavaScript 和 JSX 有什么区别? [英] What is the difference between JavaScript and JSX?

查看:50
本文介绍了JavaScript 和 JSX 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 React 的新手,我发现大多数教程都在讨论 JSX,我没有学习任何 JSX 语法,但我想知道 React 中 JavaScript 和 JSX 之间的主要用法区别是否仅在类似 HTML 的语法上?或者还有什么需要注意的?

I am pretty new to React, I find most tutorial talked about JSX, I have not learnt any JSX syntax, but I am wondering if the main usage difference between JavaScript and JSX in React is only on the HTML-like syntax? Or what else should pay attention to?

推荐答案

JS 是标准的 javascript,JSX 是一种类似于 HTML 的语法,你可以将它与 React 一起使用(理论上)使创建 React 组件变得更容易和更直观.正如文档所说,唯一的目的是为了更容易地创建 React 组件......那里没有其他东西了.如果没有 JSX,使用 JS 语法创建大型、嵌套的 HTML 文档将是一个很大的麻烦;JSX 只是让这个过程变得更简单.

JS is standard javascript, JSX is an HTML-like syntax that you can use with React to (theoretically) make it easier and more intuitive to create React components. As the docs say, the only purpose is to make it easier to create React components... there's not much else there. Without JSX, creating large, nested HTML documents using JS syntax would be a large pain in the rear; JSX simply makes that process easier.

这篇关于JavaScript 和 JSX 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆