当前位置: 首页 > news >正文

如何建设一个收费的影视图文网站主题资源网站建设 反思

如何建设一个收费的影视图文网站,主题资源网站建设 反思,网站制作出名的公司,品牌建设典型案例材料本文是react通过react-swipeable-views创建公共轮播图组件的续文 上一文 我们创建了这样的一个轮播图组件 但我们已经看到的轮播图 下面都会有小点 展示当前所在的位置 但react-swipeable-views 并没有直接提供 我们需要自己去编写这个组件 我们在components下的 rotationCh…

本文是react通过react-swipeable-views创建公共轮播图组件的续文

上一文 我们创建了这样的一个轮播图组件
在这里插入图片描述
但我们已经看到的轮播图 下面都会有小点 展示当前所在的位置
但react-swipeable-views 并没有直接提供 我们需要自己去编写这个组件

我们在components下的 rotationChart 创建一个 Pagination.jsx 组件

然后 在同目录下创建一个样式文件 我这里叫 Pagination.css
参考代码如下

.swiper-pagination{position: absolute;bottom: 10px;right: 10px;display: inline-block;height: auto;width: 100%;
}
ul {width: 100%;height: auto;text-align: center;
}
li {list-style: none;display: inline-block;height: 10px;width: 10px;border-radius: 50%;background-color:#ccc;margin: 0 3px;
}
li.selected {background-color:rgb(233,32,61);
}

Pagination.jsx 参开代码如下

import React from 'react';import './Pagination.css';export default class Pagination extends React.Component{render(){const quantity = this.props&&this.props.quantity?new Array(this.props.quantity).fill(1):[];const currentIndex = this.props&&this.props.currentIndex?this.props.currentIndex:0;return (<div className = "swiper-pagination"><ul>{quantity.map((element,index) => {return <liclassName = { currentIndex === index?'selected':'' }key = { index }></li>})}</ul></div>)}
}

这里 我们又多接收了一个参数 叫 currentIndex 判断 如果 currentIndex 和 当前下班的index相同 则给与选中状态

那么 我们来到 components/rotationChart下的index.jsx 更改代码如下

import React from 'react';
import SwipeableViews from 'react-swipeable-views';
import Pagination from './Pagination';import './index.css';export default class Swiper extends React.Component{constructor(props){super(props);this.state = {currentIndex: 0}}handleChangeIndex = (index) => {this.setState({currentIndex: index})}render(){const banners = this.props&&this.props.banners?this.props.banners:[];const height = this.props&&this.props.height?this.props.height:"200px";const width = this.props&&this.props.width?this.props.width:"400px";return (<div className = "swiper" style = { {height,width} }><SwipeableViews onChangeIndex={ this.handleChangeIndex }>{banners.map((element ,index) => {return (<div className='swiper-view' key= { index }><img src={ element } alt=""/></div>)})}</SwipeableViews><Pagination currentIndex = { this.state.currentIndex } quantity = { banners.length }/></div>)}
}

这里我们用了 react-swipeable-views组件中的 onChangeIndex函数 监听了切换事件 返回一个参数

就是当前轮播图所在的下标 然后给到 Pagination组件 运行结果如下
在这里插入图片描述
在这里插入图片描述
此时 我们下方的三个小点就实现了 因为这个组件是自己写的 如果想改样式 直接在 Pagination.css中改就好了

http://www.yayakq.cn/news/653617/

相关文章:

  • 网站开发需要用哪些东西营销型网站建设步骤
  • 新洲区城乡建设局网站怎么样引流顾客到店方法
  • 阜阳建设网站公司电话钓鱼网站怎么制作视频
  • 做58同城网站花了多少钱集团公司做网站
  • 光谷网站制作正规的报价单格式
  • 辽宁专业模板网站建设公司品牌网站设计制作哪家正规
  • 西安网站优化服务项目改造方案
  • 临沂专业网站建设公司电话网站开发常用图标 图像
  • 定制网站系统影视网站的设计与实现
  • 哪里有做网站的公司公司网站开发步骤
  • 网站友情链接模块expression wordpress主题
  • 外管局网站做延期收款报告网站建设-应酷
  • 网站建设简介电话做网站编程要学什么
  • 网站描述 修改泉州最专业微信网站建设公司
  • 大型淘宝客返利网站建设jquery 网站后台模板
  • 广州网站建设(信科分公司)什么是网站源码
  • 赣州网站开发太原网站建设公司5858
  • 高大上企业网站广州市研发网站建设平台
  • 做微商自己建网站合适吗编程网课哪家好
  • 电力建设期刊网站投稿建设网站简单教程
  • 020网站开发多少钱墨刀做网站上下滑动的交互
  • 铜川网站建设报价公路建设查询网站
  • 做阀门销售在哪个网站上做好有没有可以做游戏的网站吗
  • 如何用文档做网站计算机应用技术专业网站开发方向
  • 零食网站页面模板公司申请网站建设申请理由
  • 慕课网网站开发背景电子商务网页设计模板
  • 华强北网站建设公司2019网站怎么做
  • 昆明网站制作代理如何建开发手机网站首页
  • 台州市建设招标投标网站软件开发专业是做什么的
  • 网络推广SEO优化网站建设站长之家是干什么的