fullpage.js在vue中的使用

参考文章:https://blog.csdn.net/weixin_41192489/article/details/111104443

<template>
    <div>
        <full-page :options="options" ref="fullpage">
           <ul id="menu">
              <li  @click="handleMove(index)" :data-menuanchor="item.value" :class="index===0 ? 'active' : ''" v-for="(item,index) in menuList" :key="index">
                <a :href="'#'+item.value">{{item.label}}</a>
              </li>
          </ul>
          <div id="content">
            <div class="section">
                第一屏的内容
            </div>
            <div class="section">
                第二屏内容
            </div>
            <div class="section">
                第三屏内容
            </div>
          </div>
        </full-page>
        <div>
        </div>
    </div>
</template>
<script>
export default {
  data () {
    return {
      options: {
        // licenseKey: 'OPEN-SOURCE-GPLV3-LICENSE',
        // 是否显示导航,默认为false
        sectionsColor: ['#caf9a3', '#90ac32', '#ac932a'],
        anchors: ['page1', 'page2', 'page3'], // 注意不带#
        menu: '#menu', // 绑
        recordHistory: true
      },
      menuList: [
        {label: '首页', value: 'page1'},
        {label: '预约注册', value: 'page2'},
        {label: '游戏特色', value: 'page3'}
      ]
    }
  },

  mounted () {
    this.$refs.fullpage.api.setLockAnchors(true)
  },

  methods: {

    handleMove (index) {
      switch (index) {
        case 0:
          this.$refs.fullpage.api.moveTo(1, 0)
          break
        case 1:
          this.$refs.fullpage.api.moveTo(2, 1)
          break
        case 2:
          this.$refs.fullpage.api.moveTo(3, 2)
          break
      }
    }
  }
}
</script>
<style scoped>
ul,li{
   padding:0;
   margin:0;
   list-style:none
}
#menu{
  height: 50px;
  position: fixed;
  right: 20px;
  top: 50%;
  z-index: 20;
}
#menu li{
  width: 100px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background: #000;
  margin: 5px;
}
#menu li a{
  color: #fff;
  text-decoration: none;
}
#menu .active a{
  color: #31B0D5
}
</style>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值