.jsx+ant项目前端页面总结

一、基础部分

1、项目启动

npm install

npm run start(看配置?)

图1-访问地址

2、页面结构

图2 项目结构

 3、新增页面

图3 文件夹及路由配置

4、访问

复制图1的地址,加上项目文件夹名,如图3的页面访问地址为:

http://localhost:8000/account-review


二、页面部分

1、.jsx基础页面

 2、实现class="a b"的效果

<span className={`${styles.bl_type} ${styles.icon_mbl}`}>MB/L</span>

 3、页面 特殊字符转义

<p className={styles.textMedium}>
    我们将在<strong>{'<1个工作日内>'}</strong>完成审核,请注意查收邮件!
</p>

 4、页面引入图片

< img src={require('@/img/foo.png')} />
.icon{
    background: url(../img/icon-server.png) no-repeat;
}

 为了节省时间,less引入多倍图背景图的时候,以下代码是必须的,可直接复制

background-size: 100%;
display: inline-block;
image-rendering: -webkit-optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;

 5、多倍图在google内核浏览器下模糊

img{
  //image-rendering: -moz-crisp-edges;
  //image-rendering: -o-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  //image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
}

6、图片跳转页面

            <img
              src={require(`@/img/${lang}/banner-public.png`)}
              onClick={() => {
                history.push('/trailer-discount');
              }}
              style={{ cursor: 'pointer' }}
            />

**** 其他组件去ant官网查看即可 *****

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的音乐播放器评论界面的前端页面代码,使用了React框架和Ant Design组件库: ```jsx import React, { useState, useEffect } from 'react'; import { List, Input, Button } from 'antd'; import axios from 'axios'; const Comment = ({ songId }) => { const [comments, setComments] = useState([]); const [commentContent, setCommentContent] = useState(''); useEffect(() => { // 从后端API获取评论列表 axios.get(`/api/comments/${songId}`) .then(response => { setComments(response.data); }) .catch(error => { console.error(error); }); }, [songId]); const handleCommentSubmit = () => { // 提交评论到后端API axios.post('/api/comments', { songId, content: commentContent }) .then(response => { // 更新评论列表 setComments([...comments, response.data]); setCommentContent(''); }) .catch(error => { console.error(error); }); }; return ( <div> <h3>评论列表</h3> <List itemLayout="horizontal" dataSource={comments} renderItem={item => ( <List.Item> <List.Item.Meta title={item.user} description={item.content} /> </List.Item> )} /> <Input.TextArea rows={4} value={commentContent} onChange={e => setCommentContent(e.target.value)} /> <Button onClick={handleCommentSubmit}>提交评论</Button> </div> ); }; export default Comment; ``` 该代码定义了一个名为Comment的React组件,接受一个songId属性作为歌曲ID。组件内部使用useState和useEffect等React Hook来管理评论列表和评论内容,并使用Ant Design组件库中的List、Input和Button等组件来实现评论界面的渲染和交互。具体实现过程中需要根据实际情况进行调整和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值