请问各位大哥关于photo-sphere-viewer这个插件,为何不能加载本地资源

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8" />
        <title>Photo Sphere Viewer</title>
        <meta name="viewport" content="initial-scale=1.0" />
        <script src="../three.min.js"></script>
        <script src="../photo-sphere-viewer.min.js"></script>
        <style>
            html, body {
                margin: 0;
                width: 100%;
                height: 100%;
                overflow: hidden;
            }

            #container {
                width: 100%;
                height: 100%;
            }
        </style>
    </head>

    <body>
        <div id="container"></div>

        <script>
            var div = document.getElementById('container');
            var PSV = new PhotoSphereViewer({
                    panorama: 'http://tassedecafe.org/wp-content/uploads/2013/01/parc-saint-pierre-amiens.jpg',
                    container: div,
                    time_anim: 3000,
                    navbar: true,
                    navbar_style: {
                        backgroundColor: 'rgba(58, 67, 77, 0.7)'
                    },
                });
        </script>
    </body>

</html>

如果把panorama: 'http://tassedecafe.org/wp-con...'换成本地资源,就会报错,请问该如何解决这个问题?

阅读 9.5k
7 个回答

不能使用跨域图片,把图片下载下来放在自己的目录下引入便可以:
panorama: 'http://tassedecafe.org/wp-con...',
改成:
panorama: '自己的全景图目录地址'

你的解决了吗?为啥我本地的有的能显示,有的是黑屏啊?

新手上路,请多包涵

你好,请问这个问题你解决了吗?我现在也是这里卡住了,求助啊!

可以使用跨域的图片的。
具体方法如下:
读取跨域图片 将其进行BASE64转码再引用
效果如下
具体修改方法见http://www.zibling.site/debug...

新手上路,请多包涵

针对你的代码,container:'div'改为container: ‘container’即可

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题