当前位置:网站首页>JSX使用
JSX使用
2022-08-04 12:59:00 【monstkl】
前言:
JSX即javascript XML。不同vue的模板中写少量js脚本,JSX是在js中写html标签一、JSX中的js表达式
语法:{js表达式}
eg:
const dom = <div>你好,我是{name}</div>二、JSX的条件渲染
const sondom = () => {
if (flag) {
return <div>正确</div>
} else {
return <div>错误</div>
}
}
const fatherdom = (
<div>
{sondom()}
</div>
)三、JSX的列表渲染
const listdom = (
<ul>
{list.forEach(item => <li>{item.name}</li>)}
</ul>
)四、JSX中使用行内样式
const dom = <div style={
{color:'red',backgroundColor:'blue'}}></div>五、JSX中使用类名
在js中引入样式文件
import '../../css/index.css'
index.css中
.la-title{...}
const dom = <div className="la-title"></div>边栏推荐
猜你喜欢

Programmer Qixi Gift - How to quickly build an exclusive chat room for your girlfriend in 30 minutes

redis未授权访问漏洞【vulhub靶场】复现

倒计时 3 天|一起看云原生 Meetup 的六大议题

The head module of the yolo series

Small program on how to play in the construction of e-government service platform value

【微信小程序】信息管理与信息系统专业社会实习制作项目--垃圾指纹

他是“中台”之父,凭一个概念为阿里狂赚百亿

面试官:如何查看/etc目录下包含abc字符串的文件?

Why is Luo Zhenyu's A-share dream so difficult to fulfill?

MFC的相机双目标定界面设计
随机推荐
Small program on how to play in the construction of e-government service platform value
新消费、出海、大健康......电子烟寻找“避风港”
DateTimeFormatter api
redis未授权访问漏洞【vulhub靶场】复现
【自动微分实现】反向OO实现自动微分(Pytroch核心机制)
Just a Hook
正确使用Impala的invalidate metadata与refresh语句
两年独立开发经验程序员告诉我们赚钱的经验(听听真正赚到钱的高手做法)
Focus!2022 interview must brush 461 interview questions summary + interview + resume template
Js获取当前页面url参数
新 Nsight Graph、Nsight Aftermath 版本中的性能提升和增强功能
小程序对接企业微信客服
Opencv学习之ORB特征提取和匹配
从零开始配置 vim(6)——缩写
Programmer Qixi Gift - How to quickly build an exclusive chat room for your girlfriend in 30 minutes
面试官:如何查看/etc目录下包含abc字符串的文件?
双目立体视觉笔记(三)三角测量、极线校正
Haproxy搭建web群集
Why is Luo Zhenyu's A-share dream so difficult to fulfill?
关于mysql join 的一些说明