taro 自定义 轮播图组件
1.代码
components/MySwiper/index.js
/**
* 轮播图组件
*/
import Taro, { Component } from '@tarojs/taro';
import { Swiper, SwiperItem, Image } from '@tarojs/components';
import PropTypes from 'prop-types';
import './index.scss'; export default class MySwiper extends Component {
static propTypes = {
banner: PropTypes.array,
}; static defaultProps = {
banner: [],
}; render() {
const { banner } = this.props;
return (
<Swiper
className="swiper-container"
circular
indicatorDots
indicatorColor='#999'
indicatorActiveColor='#bf708f'
autoplay>
{ banner.map((item, index) => (
<SwiperItem key={index}>
<Image className="swiper-img" mode="widthFix" src={item.image_src}></Image>
</SwiperItem>
))}
</Swiper>
)
}
}
components/MySwiper/index.less
@import "../../styles/mixin";
.swiper-container {
width: 100vw;
height: 450px;
.swiper-img,img {
height: 450px!important;
}
}
2.调用
render() {
const { banner } = this.props;
return (
<View className="home-page">
<MySwiper banner={banner} />
</View>
)
}
3.效果图

taro 自定义 轮播图组件的更多相关文章
- vue自定义轮播图组件 swiper
1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...
- 原生JS面向对象思想封装轮播图组件
原生JS面向对象思想封装轮播图组件 在前端页面开发过程中,页面中的轮播图特效很常见,因此我就想封装一个自己的原生JS的轮播图组件.有了这个需求就开始着手准备了,代码当然是以简洁为目标,轮播图的各个功能 ...
- reactjs-swiper react轮播图组件基于swiper
react轮播图组件基于swiper demo地址:http://reactjs-ui.github.io/reactjs-swiper/simple.html 1. 下载安装 npm install ...
- 【自定义轮播图】微信小程序自定义轮播图无缝滚动
先试试效果,可以通过设置参数调整样式 微信小程序中的轮播图可以直接使用swiper组件,如下: <swiper indicator-dots="{{indicatorDots}}&qu ...
- 03 uni-app框架学习:轮播图组件的使用
1.轮播图组件的使用 参照官方文档 2.在页面上加入这个组件 3.在页面中引去css样式 并编写样式 ps:upx单位是什么 简单来说 就相当于小程序中的rpx 是一个自适应的单位 会根据屏幕宽度自动 ...
- Vue2 轮播图组件 slide组件
Vue2原生始轮播图组件,支持宽度自适应.高度设置.轮播时间设置.左右箭头按钮控制,圆点按钮切换,以及箭头.圆点按钮是否显示. <v-carousel :slideData="slid ...
- vue移动音乐app开发学习(三):轮播图组件的开发
本系列文章是为了记录学习中的知识点,便于后期自己观看.如果有需要的同学请登录慕课网,找到Vue 2.0 高级实战-开发移动端音乐WebApp进行观看,传送门. 完成后的页面状态以及项目结构如下: 一: ...
- 使用原生js将轮播图组件化
代码地址如下:http://www.demodashi.com/demo/11316.html 这是一个轮播图组件,这里是代码地址,需要传入容器的id和图片地址,支持Internet Explor ...
- bootstrap轮播图组件
一.轮播图组件模板(官方文档) <div id="carousel-example-generic" class="carousel slide" dat ...
随机推荐
- Maven实用总结
使用Maven还是推荐IDEA,以前用eclipse总是喜欢出现乱七八糟的问题,具体错误和解决方案也记不清楚了. 下面总结下IDEA中遇到的问题和解决方法: 与IDEA搭配的相关问题 如何根据模板快速 ...
- python3下安装aiohttp遇到过的那些坑
python3下安装aiohttp遇到过的那些坑 最近需要用到aiohttp这个库,在安装过程中遇到很多坑.google.baidu后,依然没有找到合适的解决方案. 后来通过去python官方的PyP ...
- git "Could not read from remote repository.Please make sure you have the correct access rights."解决方案
我们在使用git clone 或其他命令的时候,有时候会遇到这类问题,如图: fatal: Could not read from remote repository.Please make sure ...
- PM过程的一些典型场景和问题
如何进行团队激励 如何进行目标管理 如何进行绩效考核 如何处理团队沟通(技巧) 详述几种软件过程理论 需求分析和度量 测试过程和工具 开发管理过程
- 【BZOJ 4570】【SCOI 2016】妖怪
http://www.lydsy.com/JudgeOnline/problem.php?id=4570 对于每个妖怪的两个值,看成二位平面上的一个点的横纵坐标(x,y). 因为只关心a/b,所以设经 ...
- cogs 2039. 树的统计
2039. 树的统计 ★★ 输入文件:counttree.in 输出文件:counttree.out 简单对比时间限制:1 s 内存限制:128 MB [题目描述] 关于树的统计问题有 ...
- Phpstorm-php在线手册配置
php在线手册配置 第一个是浏览器软件位置 第二个是php网站写法 第三个是工作路径 C:\Users\hasee\AppData\Local\Google\Chrome\Application\ch ...
- 【转】Geary's C
李旭,Matlab: Geary's C 原文地址 Introduction Geary's C is a measure of spatial autocorrelation or an attem ...
- 【docker】【redis】2.docker上设置redis集群---Redis Cluster部署【集群服务】【解决在docker中redis启动后,状态为Restarting,日志报错:Configured to not listen anywhere, exiting.问题】【Waiting for the cluster to join...问题】
参考地址:https://www.cnblogs.com/zhoujinyi/p/6477133.html https://www.cnblogs.com/cxbhakim/p/9151720.htm ...
- LaTeX之参考文献的写法
在编写latex文件时,参考文献是个比较头疼的问题,以前自己写的时候总是用 \begin{thebibliography}\bibitem author,article, year, vol,\end ...