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

珠海微网站建设wordpress自带主题有什么用

珠海微网站建设,wordpress自带主题有什么用,红酒 专业 网站建设,模板网站定制本文是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.hyszgw.com/news/71363.html

相关文章:

  • 典型的网站开发人员手机网站免费制作
  • 网站建设 团队建筑设计怎么学 从零开始
  • 个人网站设计策划长沙网站seo技巧
  • 湖北建设厅举报网站公司法人变更流程
  • 电子商务网站建设员360搜索引擎网址
  • 自己建网站卖东西jsp网站开发源码
  • 统计局网站建设新电商运营与推广
  • 网站开发技术是什么专业会的seo培训价格
  • 爱站网关键词挖掘查询苏州竞价托管
  • 做移动网站多少钱山东济南网站建设优化
  • 局域网如何建网站西安短视频制作
  • seo博客网站给网站公司做网站
  • 网站开发注册流程以及收费wordpress 不能查看站点
  • 做网站是要编程吗高新区网站建设 意义
  • 微信做自己的网站如何做好线上营销
  • 张家港网站定制wordpress屏蔽国外ip访问
  • 中国移动深圳有限公司门户网站重庆交通在线公众号
  • 门户网站排版企业网站建设时间表
  • 品牌网站建设4a小蝌蚪网站中的表格
  • 网站开发发展趋势2018宁波做简单网站的
  • 天津做网站需要多少钱千万不要去苏州打工
  • 网站欺骗消费者怎么做哪个网站做海报比较好
  • WordPress配置全站加速cdnnginx建设网站教程
  • 企业3合1网站建设公司wordpress my02visitors
  • 企业类网站有哪些例子网站设计就业培训
  • 学风建设专题网站app平台需要多少钱
  • 手机网站源码怎么打开网页无法打开怎么办
  • 网站底部 设计网站建设风格总结
  • 携程网站建设的优缺点做ppt用什么网站
  • 网站建设捌金手指下拉七晋城市建设局网站