仿“今日头条”导航菜单左右滑动

<div class="topmenu border-bottom-cd">
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <span class="swiper-slide padding" ng-click="selectedTab($index)" ng-repeat="slide in slides" id="{{slide.id}}" style="width:auto" ng-class="{true:'font-weight-bold color-f23c39 ',false:''}[slideIndex ==$index]">{{slide.name}}</span>
      <span class="swiper-slide padding width-percentage-10" ></span>
      <span class="swiper-slide padding width-percentage-10"></span>
      <span class="swiper-slide padding width-percentage-10"></span>
      <span class="swiper-slide padding width-percentage-10"></span>
    </div>
  </div>
</div>
<ion-slide-box show-pager="false" class="has-header" on-slide-changed="slideChanged($index)">
  <ion-slide ng-repeat="slide in slides"  >
    <div class="list">
      <h2>title:{{slide.name}}</h2>
    </div>
  </ion-slide>
</ion-slide-box>


$scope.slides = [
  {name: '健康资讯',
  id:1},
  {name: '健康知识',
  id:2},
  {name: '健康问答',
  id:3},
  {name: '健康图书',
  id:4},
  {name: '健康资讯',
  id:5},
  {name: '健知识',
  id:6},
  {name: '健问答',
  id:7},
  {name: '健图书',
  id:8},
  {name: '图书',
    id:9},
  {name: '资讯',
  id:10},
  {name: '知识',
  id:11},
  {name: '问答',
  id:12},
  {name: '图书',
  id:13},
  {name: '健康资讯',
  id:14},
  {name: '健康知识',
  id:15},
  {name: '健康问答',
    id:16},
  {name: '健康图书',
  id:17},
  {name: '健康资讯',
    id:18},
];
$scope.slideIndex = 0;

//初始化swiper
var swiper = new Swiper('.swiper-container', {
  freeMode : true,
});

$scope.slideChanged = function (index) {
  $scope.slideIndex=index;
  //定位
  $location.hash( $scope.slides[index].id);
  $anchorScroll();
};
$scope.selectedTab = function (index) {
  $scope.slideIndex=index;
  //滑动索引,跳转到指定地方
  $ionicSlideBoxDelegate.slide(index)
}

使用http://www.swiper.com.cn/    
swiper.js 插件安装   npm install swiper  
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

未来-更美好

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值