基于turn.js实现的书本翻页效果(vue)

基于turn.js实现的书本翻页效果

  • vue 项目搭建 vue cli4

  • vue引入turn.js

引入jQuery

npm install jquery --save

vue.config.js文件

const webpack = require("webpack");
module.exports = {
    configureWebpack: {
        //支持jquery
        plugins: [
            new webpack.ProvidePlugin({
                $:"jquery",
                jQuery:"jquery",
                "windows.jQuery":"jquery"
            })
        ]
    },
};

全局引入turn.js

  • turn.js文件通过www.turnjs.com官网进行下载
import turn from '../assets/js/turn'

代码展示

<template>

  <div class="flipbook-viewport">
    <div class="container">
      <div class="flipbook">
        <div class="page1">
          <img :src="page1" alt="page1">
        </div>
        <div class="page2">
          <img :src="page2" alt="page1">
        </div>
        <div class="page3">
          <img :src="page3" alt="page1">
        </div>
        <div class="page4">
          <img :src="page4" alt="page1">
        </div>
        <div class="page5">
          <img :src="page5" alt="page1">
        </div>
        <div class="page6">
          <img :src="page6" alt="page1">
        </div>
        <div class="page7">
          <img :src="page7" alt="page1">
        </div>
        <div class="page8">
          <img :src="page8" alt="page1">
        </div>
        <div class="page9">
          <img :src="page9" alt="page1">
        </div>
        <div class="page10">
          <img :src="page10" alt="page1">
        </div>
        <div class="page11">
          <img :src="page11" alt="page1">
        </div>
        <div class="page12">
          <img :src="page12" alt="page1">
        </div>

      </div>
    </div>
  </div>
</template>
<script>
import $ from "jquery";
import turn from '../assets/js/turn'
export default {
  name: "E-book",
  data() {
    return{
      page1: require('../assets/img/pages/1.jpg'),
      page2: require('../assets/img/pages/2.jpg'),
      page3: require('../assets/img/pages/3.jpg'),
      page4: require('../assets/img/pages/4.jpg'),
      page5: require('../assets/img/pages/5.jpg'),
      page6: require('../assets/img/pages/6.jpg'),
      page7: require('../assets/img/pages/7.jpg'),
      page8: require('../assets/img/pages/8.jpg'),
      page9: require('../assets/img/pages/9.jpg'),
      page10: require('../assets/img/pages/10.jpg'),
      page11: require('../assets/img/pages/11.jpg'),
      page12: require('../assets/img/pages/12.jpg'),
    }
  },
  mounted() {
    this.$nextTick(() => {
        // Create the flipbook
        $('.flipbook').turn({
          width:922,
          height:600,
          elevation: 50,
          gradients: true,
          autoCenter: true
        });
    });
  },
  methods: {},
  components: {}
};
</script>

<style scoped lang="less">
img{
  height: 600px;
  width: 461px;
}
.flipbook-viewport{
  background: url("../assets/img/bg.jpg") no-repeat;
  background-size:100% 100%;
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值