<template> <view class="seePhoto"> <swiper :current="renderCurrent" @change="swiperChange" > <swiper-item style="width:100%;height: 100%;" v-for="(val,key) in renderPhoto" :key="key"> </swiper-item> </swiper> </view> </template> <script> export default{ data(){ return{ renderPhoto:[],//要渲染的图片 只沉染二张图进行来回切换 renderCurrent: 1,//轮播时的索引 lastCurrent:1,//记录上一次的索上,用于判断是左滑动还是右滑动 } }, methods:{ // 滑动时 swiperChange(e){ let that = this; this.renderCurrent = e.detail.current; if(this.photoArr.length > 3){ // 右滑动 0 1 2 0 1 2 // 左滑动 2 1 0 2 1 0 if(e.detail.current != (this.renderPhoto.length -1) && e.detail.current > this.lastCurrent){ console.log("左滑动了") } else if(e.detail.current == (this.renderPhoto.length -1) && e.detail.current > this.lastCurrent && this.lastCurrent != 0){ console.log("左滑动了") } else if(e.detail.current == 0 && this.lastCurrent == (this.renderPhoto.length -1)){ console.log("左滑动了") } else if(e.detail.current != 0 && e.detail.current < this.lastCurrent){ console.log("右滑动了") } else if(e.detail.current == 0 && e.detail.current < this.lastCurrent){ console.log("右滑动了") } else if(e.detail.current == (this.renderPhoto.length -1) && e.detail.current > this.lastCurrent && this.lastCurrent == 0){ console.log("右滑动了") } this.lastCurrent = e.detail.current; } }, } } </script>
swiper可以判断划动方向吗?swiper能不能加上,判断划动方向的功能
2023-07-24SystemError (appServiceSDKScriptError) I.g.Canvas is not a constructor TypeError: I.g.Canvas is not a constructor at eval (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:1581890) at new oP (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:1582101) at DD (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:1621791) at eval (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:1622650) at Generator.next (<anonymous>) at n (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:2698) at s (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:2901) at eval (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:48377) at n (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:24712) at A.b.<computed> (eval at n.call.document (http://127.0.0.1:38096/remote-debug/runtime.js?devtools_ignore=true:1:15449), <anonymous>:2:35159)
[开发者工具] 真机调试报错:SystemError (appServiceSDKScriptEr?很奇怪,这几天在做真机调试的时候,就报这个错: WAServiceMainContext.js:formatted:13869 SystemError (appServiceSDKScriptError) "expected not same" String 之前还是好好的,并没改什么配置啊;另外非真机调试的时候,所有功能都是好好的。 实在搞不懂,希望有哪位大侠帮忙看一下。 谢谢。 [图片] [图片]
2022-12-24