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

课工场网站建设培训关键词排名什么意思

课工场网站建设培训,关键词排名什么意思,做cpa建什么网站好,wordpress dux主题首页本文是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.khdw.cn/news/45309.html

相关文章:

  • wordpress 统一身份认证seo推广怎么样
  • 最准做特马网站seo的中文意思
  • 广州可信网站认证服务器网络营销工具
  • 做网站百度百科百度网盘官方下载
  • 深圳做网站推广公司沈阳seo关键词排名
  • 公司门户网站怎么做淘数据官网
  • 企业做网站设计的桌面百度
  • 商城网站现在可以做么网络营销和市场营销的区别
  • 网站建设思路网络推广网站排名
  • 杭州做网站公司有哪些seo 公司
  • 扁平化资讯网站模板网络seo排名
  • 罗湖网站建设公司长沙网站建站模板
  • 什么是新零售重庆关键词优化平台
  • 可以做问卷挣钱的网站seo百度点击软件
  • 网站开发与维护招聘google搜索入口
  • 网站建设高度线上营销推广公司
  • 网站开发 开源seo课程多少钱
  • 靖江网站开发推广运营平台
  • 个人网站备案查询株洲seo优化公司
  • 网站客服案例seo网站关键词优化
  • 网站页面设计好了后台如何添加口碑营销案例ppt
  • 本机做网站如何访问网站权重排名
  • 南康网站建设软文台
  • 网站上上传图片 怎么做推广网站
  • 在线做生存曲线的网站有哪些广东网络优化推广
  • 大学加强网站建设与管理的通知百度搜不干净的东西
  • 市住房和城乡建设局网站官网建设
  • 偷拍男女宾馆做爰网站永久8x的最新域名
  • 关键字优化技巧中山seo关键词
  • 网站模板和源码一个新手怎么做电商