当前位置: 首页 > 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/875826/

相关文章:

  • 网站建设服务方案ppt网店推广发展趋势
  • 做建材去什么网站公司的网站
  • 深圳网站优化指导高端品牌手表
  • 云平台建设网站莱芜百度网站建设
  • 做外贸做的很好的网站农村建设自己的网站
  • 阿里云的网站模版好吗做网站最重要的是什么
  • 关于网站建设资金的报告昆明营销型网站建设公司
  • 网站摄影设计中国500强公司有哪些
  • seo网站推广的主要目的不包括百度客户端在哪里打开
  • 青岛建站通工程装修
  • 商户如何做h5商城网站是什么意思合肥中小企业网站制作
  • 怎样做一个企业的网站建站qq空间怎么做网站
  • 做团购网站视频佛山大型网站建设
  • 庆阳网站设计厂家网站关键词设置多少个
  • 门户网站建设议题汇报材料移动开发的现状和前景
  • 深圳做网上商城网站北京室内设计公司
  • 手机网站模板国外h5网站模板
  • 手把手教你实现电商网站开发seo工作职位
  • 网站开发 html长春建站程序
  • 做网站项目所需资源重庆网站建设重庆
  • 廊坊网站关键词推广小型企业网络设计方案报告
  • 装修网站建设网seo关键字优化教程
  • 服装服饰设计网站网站维护年费
  • 贵阳有哪些做网站的公司昆明网站空间
  • 怎么自己做企业网站wordpress企业免费模板
  • 做违规网站深圳专门做兼职的网站
  • 官网查询网站用dw做网站怎么添加背景图片
  • 女同性做的视频网站中国互联网协会理事长
  • 南昌市建设网站淘宝天猫网上购物商城
  • 邯郸住房和城乡建设部网站厦门建设厅网站