曾经使用过ionic提供的segment + slides 实现,无奈滑动的时候总感觉有点问题,后来改用swiper代替slides,用起来感觉不错。
1. swiper官网地址
http://www.swiper.com.cn/api/index.html
2. 下载swiper
http://www.swiper.com.cn/download/index.html
3. 导入到项目

4. 初始化
4.1 初始化segment

在对应的ts中

设置默认选择第一个

4.2 初始化swiper


当页面滑动时,改变segment的值
当用segment 进行切换时,切换swiper页面。如果不使用分页懒加载,请忽略判断代码

5. 效果

网友评论