我正在使用照片球插件。我想在多个地方使用这个脚本。
<div class="container bs-docs-container">
<div class="row">
<div class="col-md-6" role="main">
<section class="bs-docs-section">
<div id="photosphere"></div>
</section>
</div>
<div class="col-md-6" role="main">
<section class="bs-docs-section">
<div id="photosphere1"></div>
</section>
</div>
</div>
var PSV = new PhotoSphereViewer({
panorama: 'img/Bryce-Canyon-National-Park-Mark-Doliner.jpg',
container: 'photosphere',
caption: 'Photo',
loading_img: 'img/photosphere-logo.gif',
navbar: 'autorotate zoom download caption fullscreen',
default_fov: 70,
mousewheel: true,
size: {
height: 500
}
});
var PSV = new PhotoSphereViewer({
panorama: 'img/Bryce-Canyon-National-Park-Mark-Doliner.jpg',
container: 'photosphere1',
caption: 'Photo',
loading_img: 'img/photosphere-logo.gif',
navbar: 'autorotate zoom download caption fullscreen',
default_fov: 70,
mousewheel: true,
size: {
height: 500
}
});而不是在我想要在多个地方使用的脚本中添加容器:“光子球”,容器:“光圈1”,。我已经提到下面的演示网址。
发布于 2017-12-29 06:39:46
使PhotoSphereViewer分离函数并将div id作为参数传递给该函数。在任何时候使用div id(容器id)调用这个函数。
function psvDivFun(idname)
{
var PSV = new PhotoSphereViewer({
panorama: 'img/Bryce-Canyon-National-Park-Mark-Doliner.jpg',
container: idname,
caption: 'Photo',
loading_img: 'img/photosphere-logo.gif',
navbar: 'autorotate zoom download caption fullscreen',
default_fov: 70,
mousewheel: true,
size: {
height: 500
}
});
}
psvDivFun('photosphere');
psvDivFun('photosphere1');不要忘记将“idname”分配给容器。
container: idname,https://stackoverflow.com/questions/48018318
复制相似问题