示例代码
安装photo-sphere-viewer
yarn add -D photo-sphere-viewer
组件引入插件
import { Viewer } from 'photo-sphere-viewer';
import 'photo-sphere-viewer/dist/photo-sphere-viewer.css'; // 引入样式
import MarkersPlugin from 'photo-sphere-viewer/dist/plugins/markers'; // 引入标记
完整组件
<template>
<div class="PSViewer" ref="psvdbg" :style="{height:height,width:width}"></div>
</template>
<script>
import { Viewer } from 'photo-sphere-viewer';
import 'photo-sphere-viewer/dist/photo-sphere-viewer.css';
import MarkersPlugin from 'photo-sphere-viewer/dist/plugins/markers';
import BaseImg from "./base.jpg";
export default {
name: 'quanjing3D',
props: {
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '700px'
}
},
data() {
return {
img: BaseImg
};
},
mounted() {
this.init();
},
methods: {
init() {
var PSV = new Viewer({
panorama: this.img, //图片
caption: '室内',
container: this.$refs.psvdbg, //id
size: {
width: '100%',
height: this.$refs.psvdbg.offsetHeight
},
navbar: ['autorotate', 'zoom', 'caption', 'fullscreen'],
plugins: [
[
MarkersPlugin,
{
markers: [
{
id: 'image',
longitude: 0.931,
latitude: 0.3,
image: require('./exit.png'),
anchor: 'bottom center',
width: 48,
height: 48,
tooltip: 'A image marker. <b>Click me!</b>',
content: '这是一个marker标记'
},
{
// 具有自定义样式的html标记
id: 'text',
longitude: 0,
latitude: 0,
html: 'HTML <b>marker</b> ♥',
anchor: 'bottom right',
style: {
maxWidth: '100px',
color: 'white',
fontSize: '20px',
fontFamily: 'Helvetica, sans-serif',
textAlign: 'center'
},
tooltip: {
content: '一个标记',
position: 'right'
}
}
]
}
]
]
});
PSV.on('click', function(e) {
// console.log(e);
// console.log(MarkersButton);
// console.log(PSV.buttons.MarkersButton);
});
}
}
};
</script>
<style lang="scss" scoped>
</style>
视频号如何做视频任务进行变现
2023-09-05
视频号如何插入带货商品链接进行变现
2023-09-04
36岁男子自称被裁,曾是前500强公司市场总监,最后接受做外买
2023-09-03
聊一下互联网红利并牢牢抓住
2023-09-02
关于大学考研与不考研自己一点看法
2023-09-01
css中文本阴影特效
2023-08-30
(能绘画,能问答)
(添加社群,拓展人脉)