简单说一下准备工作
安装 photo-sphere-viewer依赖
在你需要用到的页面引入文件
接下来就可以正常使用了
项目需要用线上的图片并且需要点击进行切换图片。下面是用来实现图片切换的,在pc端以及Android上都没有问题。
但是…在ios上展示的时候图片没出来,也没有Cannot load image的报错,初步判断应该不是图片路径的问题。尝试换一种切换图片的方式。如下
此时在ios上是可以显示的,但是…哈哈哈又有了新的问题,在切换频率高时这个方法报错PSVError: Loading already in progress大概意思就是上个图还没加载完,这样我们在切换的时候可能导致图片不显示。。所以,我们将点击事件做个限制,如下
//定义了一个变量imageLoaded来判断是否加载完成,在每次切换时设为false
//然后我们就可以在点击事件的位置通过imageLoaded的值来限制