vue 仿照抖音视频效果(滑动切换)vant2

3 篇文章 0 订阅
2 篇文章 0 订阅

看个效果图,再决定学不学

================

好像还凑合吧

那就学起来吧~~~~~~~~~~~~~~~~~~~~~~~

<template>
  <div class="container_box" id="video_box">
    <div class="van_swipe">
      <!--vant van-swipe 滑动组件 -->
      <van-swipe
        :show-indicators="false"
        @change="onChange"
        vertical
        :loop="false"
        ref="swipe"
      >
        <van-swipe-item
          v-for="(item, index) in videoList"
          :key="index"
          class="product_swiper"
        >
          <div class="video_container">
            <video
              class="video_box"
              width="100%"
              height="100%"
              webkit-playsinline="true"
              x5-playsinline=""
              x5-video-player-type="h5"
              x5-video-player-fullscreen=""
              playsinline
              preload="auto"
              :poster="item.cover"
              :src="item.url"
              :playOrPause="playOrPause"
              x-webkit-airplay="allow"
              x5-video-orientation="portrait"
              @click="pauseVideo"
              @ended="onPlayerEnded($event)"
              loop="loop"
            ></video>
            <!-- 封面 -->
            <img
              v-show="isVideoShow"
              class="play"
              @click="playvideo"
              :src="item.cover"
            />
            <!-- 播放暂停按钮 -->
            <img
              v-show="iconPlayShow"
              class="icon_play"
              @click="playvideo"
              src="../resource/icon_play.png"
            />
          </div>
          <!-- 右侧点赞、分享功能 -->
          <div class="tools_right">
            <div class="tools_r_li" @click="changeFollow(item, index)">
              <i
                class="iconfont icon-yixianshi-"
                :class="item.follow ? 'follow_active' : ''"
              ></i>
              <div class="tools_r_num">{{item.loveCount}}w</div>
            </div>
            <div class="tools_r_li" @click="changeShare">
              <i class="iconfont icon-tubiao-"></i>
              <div class="tools_r_num">{{item.shareCount}}w</div>
            </div>
          </div>
          <!-- 底部作品描述 -->
          <div class="production_box">
            <div class="production_name">@{{item.name}}</div>
            <div class="production_des">
              <i
                v-for="(list, index) in item.buyShopList" 
                :key="index" 
                class="production_des_i"
                @click="copyShopName(list.ShopUrl)"
              >
                {{list.ShopName}}
              </i>
            </div>
          </div>
        </van-swipe-item>
      </van-swipe>
      <!--底部操作栏-->
      <div class="container_bottom">
        <div
          class="bottom_tab"
          :class="tabIndex == 0 ? 'tab_active' : ''"
          @click="changeTab(0)"
        >
          <span class="bottom_tab_span">首页</span>
        </div>
        <div
          class="bottom_tab"
          :class="tabIndex == 1 ? 'tab_active' : ''"
          @click="changeTab(1)"
        >
          <span class="bottom_tab_span">设置</span>
        </div>
      </div>
      <!--分享弹框-->
      <div class="share_hover"></div>
      <div class="share_box" :class="showShareBox ? 'share_active' : ''">
        <div class="share_tips">分享到</div>
        <ul class="share_ul">
          <li class="share_li pengyouquan_li">
            <i class="iconfont icon-pengyouquan"></i>
          </li>
          <li class="share_li">
            <i class="iconfont icon-weixin"></i>
          </li>
          <li class="share_li" @click="copyUrl">
            <i class="iconfont icon-lianjie"></i>
          </li>
          <div class="clear"></div>
        </ul>
        <div class="share_cancel" @click="cancelShare">取消</div>
      </div>
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import { Swipe, SwipeItem, Toast } from "vant";
Vue.use(Swipe).use(SwipeItem);
export default {
  name: "videoChild",
  data() {
    let u = navigator.userAgent;
    return {
      current: 0,
      videoList: [
        {
          url: "https://video.pearvideo.com/mp4/third/20201113/cont-1706821-15126082-111655-hd.mp4",
          cover: "https://image-cn2.tvcbook.com/v7/image/2020/11/13/8a7b666e-0ac8-4e34-b549-8360b1569e54.png!cover-780-439?x-oss-process=image/crop,x_0,y_72,w_1080,h_608,g_nw",
          follow: false,
          loveCount: 24,
          shareCount: 12,
          name: '智.混动',
          buyShopList: [
            {
              ShopName: '淘宝',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '天猫',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '京东',
              ShopUrl: 'http://taobao.com'
            }
          ]
        },
        {
          url: "https://video.pearvideo.com/mp4/third/20201114/cont-1707004-15488237-105621-hd.mp4",
          cover: "https://image-cn2.tvcbook.com/daq/2020/11/12/de65881c-24b0-11eb-84ef-02420a0008fb.png!cover-780-439",
          follow: false,
          loveCount: 28,
          shareCount: 2,
          name: '用jio看世界,发现更多乐趣',
          buyShopList: [
            {
              ShopName: '淘宝',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '天猫',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '拼多多',
              ShopUrl: 'http://taobao.com'
            }
          ]
        },
        {
          url: "https://video.pearvideo.com/mp4/third/20201117/cont-1707360-15126082-105138-hd.mp4",
          cover: "https://image-cn2.tvcbook.com/v7/thumbs/17e6bd9a691e4066b94feb8c5e0c2e84-mp4-hd/snapshots/17e6bd9a691e4066b94feb8c5e0c2e84-00053.jpg!cover-780-439",
          follow: false,
          loveCount: 48,
          shareCount: 23,
          name: '三维',
          buyShopList: [
            {
              ShopName: '淘宝',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '天猫',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '苏宁',
              ShopUrl: 'http://taobao.com'
            }
          ]
        },

        {
          url: "https://video.pearvideo.com/mp4/third/20201111/cont-1706407-15488237-112532-hd.mp4",
          cover: "https://image-cn2.tvcbook.com/v7/image/2020/11/17/73fdf11d-ea43-4a5c-b864-e8082af3d8c0.JPG!cover-780-439?x-oss-process=image/crop,x_0,y_0,w_1920,h_1080,g_nw",
          follow: false,
          loveCount: 68,
          shareCount: 29,
          name: '世界关节炎日 MoveFree奶奶的约定',
          buyShopList: [
            {
              ShopName: '淘宝',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '天猫',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '苏宁',
              ShopUrl: 'http://taobao.com'
            }
          ]
        },
        {
          url: "https://video.pearvideo.com/mp4/third/20201124/cont-1708555-15126082-104309-hd.mp4",
          cover: "https://image-cn2.tvcbook.com/daq/2020/11/17/7c7b0cbc-2893-11eb-9c33-02420a0008fb.png!cover-780-439",
          follow: false,
          loveCount: 168,
          shareCount: 129,
          name: '黑无节,是他们的限定狂欢日',
          buyShopList: [
            {
              ShopName: '淘宝',
              ShopUrl: 'http://taobao.com'
            },
            {
              ShopName: '天猫',
              ShopUrl: 'http://taobao.com'
            }
          ]
        },
        {
          url: "https://video.pearvideo.com/mp4/third/20201124/cont-1708555-15126082-104309-hd.mp4",
          cover: "https://image-cn2.tvcbook.com/daq/2020/11/17/d73b7026-287d-11eb-9c33-02420a0008fb.png!cover-780-439",
          follow: false,
          loveCount: 18,
          shareCount: 1,
          name: '懂咖啡,也懂你的小心思',
          buyShopList: [
            {
              ShopName: '淘宝',
              ShopUrl: 'http://taobao.com'
            }
          ]
        }
      ],
      isVideoShow: true,
      playOrPause: true,
      video: null,
      iconPlayShow: true,
      isAndroid: u.indexOf("Android") > -1 || u.indexOf("Adr") > -1,
      isiOS: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
      tabIndex: 0,
      showShareBox: false,
      loveCount: 0
    };
  },
  methods: {
    //改变菜单
    changeTab(index) {
      this.tabIndex = index;
      if (index === 1) {
        this.$router.push('/about')
      }
    },
    //改变收藏状态
    changeFollow(item, index) {
      this.videoList[index].follow = !this.videoList[index].follow;
    },
    //展示分享弹窗
    changeShare() {
      this.showShareBox = true;
    },
    //取消分享
    cancelShare() {
      this.showShareBox = false;
    },
    //滑动改变播放的视频
    onChange(index) {
      //改变的时候 暂停当前播放的视频
      let video = document.querySelectorAll("video")[this.current];
      video.pause();
      this.playOrPause = false;
      this.current = index;
      if (this.isiOS) {
        //ios切换直接自动播放下一个
        this.isVideoShow = false;
        this.pauseVideo();
      } else {
        //安卓播放时重置显示封面。图标等
        this.isVideoShow = true;
        this.iconPlayShow = true;
      }
    },
    loveCountRadom(count) {
      let arr = [12, 67, 34, 76.9, 12.9, 24, 1.9, 45, 4.6]
      return arr[count]
    },
    playvideo() {
      let video = document.querySelectorAll("video")[this.current];
      console.log(video.play());
      console.log("playvideo:" + this.current);
      this.isVideoShow = false;
      this.iconPlayShow = false;
      video.play();
      window.onresize = function () {
        video.style.width = window.innerWidth + "px";
        video.style.height = window.innerHeight + "px";
      };
    },
    pauseVideo() {
      //暂停\播放
      let video = document.querySelectorAll("video")[this.current];
      console.log("pauseVideo" + this.current);
      this.loveCount = this.loveCountRadom(this.current)
      if (this.playOrPause) {
        video.pause();
        this.iconPlayShow = true;
      } else {
        video.play();
        this.iconPlayShow = false;
      }
      this.playOrPause = !this.playOrPause;
    },
    onPlayerEnded() {
      //视频结束
      this.isVideoShow = true;
      this.current++;
      this.$refs.swipe.next()
    },
    //复制当前链接
    copyUrl() {
      Toast('复制链接成功')
      let httpUrl = window.location.href;
      var oInput = document.createElement("input");
      oInput.value = httpUrl;
      document.body.appendChild(oInput);
      oInput.select(); // 选择对象
      document.execCommand("Copy"); // 执行浏览器复制命令
      oInput.className = "oInput";
      oInput.style.display = "none";
    },
    copyShopName(ShopUrl) {
      Toast('复制成功')
    }
  },
};
</script>
<style scoped>
.video-player {
  height: 100%;
  width: 100%;
}
.van_swipe {
  width: 100%;
  height: 100%;
}
.van-swipe {
  width: 100%;
  height: 100%;
}
.container_box {
  width: 100%;
  height: 660px;
}
.video_box {
  object-fit: cover !important;
  z-index: 999;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
}
video {
  object-position: 0 0;
}
.icon_play {
  position: absolute;
  top: 44%;
  right: 0;
  left: 0;
  bottom: auto;
  margin: auto;
  z-index: 999;
  height: 60px;
  /* background: rgba(0, 0, 0, 0.5); */
  border-radius: 50%;
}
.play,
.platStart {
  position: absolute;
  margin: auto;
  top: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 100%;
}
/* 点赞,转发 */
.tools_right {
  z-index: 1001;
  position: absolute;
  right: 16px;
  bottom: 238px;
}
.tools_r_li {
  margin-bottom: 20px;
  color: #fff;
  font-size: 16px;
}
.tools_r_li:last-child {
  margin-bottom: 0px;
}
.icon_right {
  margin-bottom: 5px;
  font-size: 42px;
  display: block;
  text-shadow: 0px 0px 10px #9d9d9d;
  /*transition: .5s;*/
}
.production_box {
  z-index: 1001;
  position: absolute;
  /* right: 16px; */
  bottom: 54px;
  text-align: left;
  padding: 0 15px 15px 15px;
  color: #fff;
  width: 100%;
  left: 0;
  box-sizing: border-box;
  background: -webkit-linear-gradient(
    top,
    rgba(0, 0, 0, 0.2),
    rgba(0, 0, 0, 0)
  ); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(
    top,
    rgba(0, 0, 0, 0.2),
    rgba(0, 0, 0, 0)
  ); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(
    top,
    rgba(0, 0, 0, 0.2),
    rgba(0, 0, 0, 0)
  ); /* Firefox 3.6 - 15 */
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.2),
    rgba(0, 0, 0, 0)
  ); /* 标准的语法 */
}
.production_name {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 10px;
  color: #fda085;
}
.production_des {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  min-height: 62px;
}
.production_des_i {
  font-style: normal;
  font-weight: 700;
  color: #fda085;
}
.container_bottom {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  height: 60px;
  border-top: 1px solid rgba(255, 255, 255, 0.7);
}
.production_top {
  display: inline-block;
  padding: 6px;
  margin-bottom: 5px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  margin-top: 5px;
}
.product_go {
  color: #fbdd21;
}
.production_title {
  margin-left: 4px;
}
.bottom_tab {
  width: 50%;
  text-align: center;
  float: left;
  color: #c9c9c9;
  padding: 10px 0;
}
.bottom_tab_span {
  line-height: 30px;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  font-size: 16px;
  display: inline-block;
  /* padding: 0 4px; */
  transition: 0.5s all;
}
.tab_active .bottom_tab_span {
  border-bottom: 2px solid #fda085;
  color:#fda085;
}
.icon-shoucang {
  transition: 0.5s all;
}
.follow_active {
  color: #fda085;
  animation: showHeart 0.5s ease-in-out 0s;
}
@keyframes showHeart {
  0% {
    color: #f44;
    transform: scale(1);
  }
  25% {
    color: #fff;
    transform: scale(0);
  }
  80% {
    color: #f44;
    transform: scale(1.2);
  }
  100% {
    color: #f44;
    transform: scale(1);
  }
}
/*分享样式*/
.share_hover {
  position: fixed;
  display: none;
}
.share_box {
  position: fixed;
  bottom: -300px;
  width: 100%;
  z-index: 1002;
  background: #fff;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  transition: 0.5s;
}
.share_tips {
  text-align: center;
  line-height: 38px;
  color: #333;
}
.share_ul {
  box-sizing: border-box;
  padding: 0 25px 25px;
  border-bottom: 1px solid #e8e8e8;
}
.share_li {
  float: left;
  width: 33%;
  text-align: center;
}
.share_li i {
  font-size: 22px;
}
.share_cancel {
  text-align: center;
  line-height: 48px;
  color: #777;
  text-align: center;
}
.pengyouquan {
  color: #47d000;
}
.pengyouquan_li {
  animation: rotating 8s linear infinite;
}
@keyframes rotating {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}
.weixin {
  color: #20ca2e;
}
.lianjie {
  color: #cdcdcd;
}
.share_active {
  bottom: 0px;
}
</style>

代码已经放在他的 gitee,大家可以看看

同时他也在 github 上发现一位大佬做的这种效果也特别好https://github.com/maomincoding/zm_mv2

这是大佬的主要代码,感兴趣的小伙伴可以去看看。

<template>
  <div class="home">
    <van-swipe
      style="height: 100vh"
      vertical
      @change="onChange"
      :show-indicators="false"
    >
      <van-swipe-item>
        <div class="main" v-if="isshow">
          <video-player
            v-if="playerOptions.sources[0].src"
            class="video-player vjs-custom-skin"
            ref="videoPlayer"
            :playsinline="true"
            :options="playerOptions"
          ></video-player>
          <div class="footbox">
            <div class="foot">
              <p class="user">@ {{ artistName }}</p>
              <p class="name">{{ name }}</p>
            </div>
            <div class="pl" @click="openPl">
              <van-icon name="chat" size="30" />
            </div>
          </div>
        </div>
      </van-swipe-item>
      <van-swipe-item>
        <div class="main" v-if="!isshow">
          <video-player
            v-if="playerOptions.sources[0].src"
            class="video-player vjs-custom-skin"
            ref="videoPlayer"
            :playsinline="true"
            :options="playerOptions"
          ></video-player>
          <div class="footbox">
            <div class="foot">
              <p class="user">@ {{ artistName }}</p>
              <p class="name">{{ name }}</p>
            </div>
            <div class="pl" @click="openPl">
              <van-icon name="chat" size="30" />
            </div>
          </div>
        </div>
      </van-swipe-item>
    </van-swipe>
    <van-action-sheet v-model="show" class="sheet">
      <van-list
        v-model="loading"
        @load="onLoad"
        :offset="1"
        :immediate-check="false"
      >
        <div v-for="(item, index) in plist" :key="index" class="ovf pll">
          <div class="pl-l"><img :src="item.user.avatarUrl" alt="" /></div>
          <div class="pl-r">
            <div class="name1">{{ item.user.nickname }}</div>
            <div class="con">{{ item.content }}</div>
          </div>
        </div>
      </van-list>
    </van-action-sheet>
  </div>
</template>

<script>
import { list, mv, pl } from "@request/api";
import "../video/index";
import { videoPlayer } from "vue-video-player";
export default {
  name: "home",
  data() {
    return {
      list: "",
      id: "",
      show: false,
      dataLength: 1,
      inx: 0,
      artistName: "",
      name: "",
      isshow: true,
      plist: "",
      loading: false,
      page: 10,
      playerOptions: {
        autoplay: true, //如果true,浏览器准备好时开始回放。
        muted: false, // 默认情况下将会消除任何音频。
        loop: false, // 导致视频一结束就重新开始。
        preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
        language: "zh-CN",
        poster:"",
        aspectRatio: "16:9", // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
        fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
        sources: [{ type: "video/mp4", src: "" }],
        width: document.documentElement.clientWidth,
        notSupportedMessage: "此视频暂无法播放,请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
        controlBar: {
          timeDivider: true, // 分时
          durationDisplay: true, // 持续时间显示
          remainingTimeDisplay: false, // 剩余时间显示
          fullscreenToggle: false, //全屏按钮
        },
      },
    };
  },
  components: {
    videoPlayer,
  },
  mounted() {
    this.wait();
  },
  methods: {
    // 首次获取url
    async wait() {
      let id = await this.get();
      let res = await mv(id);
      // this.playerOptions.poster = this.poster;
      this.$set(this.playerOptions, "poster", this.poster);
      this.$set(this.playerOptions.sources[0], "src", res.data.url);
    },
    // 加载评论
    onLoad() {
      setTimeout(() => {
        this.page += 10;
        this.getpl();
        this.loading = false;
      }, 500);
    },
    // 获取数据
    get() {
      return list(this.dataLength).then((res) => {
        console.log(res.data);
        this.urlData = res.data;
        this.poster = this.urlData[this.inx].cover;
        this.id = this.urlData[this.inx].id;
        this.artistName = this.urlData[this.inx].artistName;
        this.name = this.urlData[this.inx].name;
        // return this.id;
        return Promise.resolve(this.id);
        // 等价于
        // return new Promise((resolve) => {
        //   resolve(this.id)
        // })
      });
    },
    // 封装静态数据
    getStatic(v) {
      this.id = v[this.inx].id;
      this.artistName = v[this.inx].artistName;
      this.name = v[this.inx].name;
      this.poster = v[this.inx].cover;
      return this.id;
    },
    // 获取评论
    getpl() {
      pl(this.id, this.page).then((res) => {
        if (document.querySelector(".van-action-sheet__content")) {
          document.querySelector(".van-action-sheet__content").scrollTop = 0;
        }
        this.plist = res.comments;
      });
    },
    // 滑动触发
    async onChange() {
      console.log(this.inx);
      this.isshow = !this.isshow;
      this.page = 10;
      this.getpl();
      if (this.inx < this.urlData.length - 1) {
        this.inx += 1;
        let id = this.getStatic(this.urlData);
        let res = await mv(id);
        this.$set(this.playerOptions.sources[0], "src", res.data.url);
        this.$set(this.playerOptions, "poster", this.poster);
        // this.playerOptions.poster = this.poster;
      } else {
        this.inx = 0;
        this.dataLength += 1;
        this.wait();
      }
    },
    // 打开评论列表
    openPl() {
      this.show = true;
      this.getpl();
    },
  },
};
</script>
<style lang="less" scoped>
.main {
  height: 100%;
}
.footbox {
  position: relative;
  bottom: 0;
  width: 95%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user {
  font-size: 14px;
}
.user,
.name {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.foot {
  width: 80%;
  color: #fff;
  font-size: 16px;
  z-index: 10001;
}
.pl {
  width: 10%;
  color: #fff;
  font-size: 16px;
  z-index: 10001;
}
.sheet {
  height: 50vh;
  .pll {
    overflow: hidden;
    padding: 10px;
    border-bottom: 1px solid #f4f4f4;
    .pl-l {
      width: 20%;
      float: left;
    }
    .pl-l img {
      width: 55%;
      border-radius: 50%;
      animation: all ds 0.5s;
    }
    @keyframes ds {
      from {
        opacity: 0;
      }
      to {
        opacity: 1;
      }
    }
    .pl-r {
      width: 78%;
      float: left;
    }
    .name1 {
      font-size: 14px;
      color: #666;
      font-weight: bold;
      margin-bottom: 5px;
    }
    .con {
      width: 100%;
      line-height: 24px;
      color: #333333;
      font-size: 14px;
    }
  }
}
</style>

代码参考文章:https://redelego.blog.csdn.net/article/details/87881899?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.channel_param

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Uniapp是一款基于Vue.js开发的跨平台应用框架,可以用于开发Android、iOS及Web等多个平台的应用程序。要实现仿抖音视频滑动效果,可以按照以下步骤进行操作: 1. 创建一个新的Uniapp项目,并引入需要的库和组件。 2. 在主页面中,使用Scroll View组件作为视频列表的滚动容器,设置滑动方向为水平。 3. 在Scroll View组件内添加一个横向滑动的容器(例如swiper组件),用于存放每个视频的播放窗口。 4. 定义一个数据源(例如videoList),用于存放所有视频的信息,包括视频的路径、封面图等。 5. 遍历videoList数据,动态生成每个视频的播放窗口,并设置其宽度和高度。 6. 实现左右滑动效果,可以使用Touch事件监听滑动动作,根据触摸开始和结束时的坐标差值来判断滑动方向。 7. 根据滑动的距离和方向,计算视频播放窗口的位置偏移量,实现滑动过程中窗口的平移效果。 8. 针对不同的滑动行为(如滑动到下一个视频滑动到上一个视频),可以通过监听滑动结束事件,根据当前播放窗口的位置和滑动方向,判断所需播放的视频,并更新页面。 总结起来,要实现uniapp仿抖音视频滑动效果,需要使用Scroll View和swiper组件来构建滑动容器和视频播放窗口,根据滑动事件和滑动方向来控制视频窗口的位置和播放顺序。同时,需要借助数据源(videoList)来存放视频的信息,实现动态生成和更新视频窗口。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值