前言
由于工作的需求,要实现全景图片的展示与预览,本来以为会是一个很难的内容,没想到使用现成的组件photo-sphere-viewer就可以轻松实现,上手只需要10分钟!
一、引入photo-sphere-viewer?
可以直接通过npm进行引入
npm install photo-sphere-viewer
二、使用步骤
1.引入库
photo-sphere-viewer 都是采用按需引入,用到哪个模块就引入哪个模块
import {
Viewer} from 'photo-sphere-viewer' // 引入组件
import 'photo-sphere-viewer/dist/photo-sphere-viewer.css' // 引入样式
2.声明容器
在Vue文件中声明一个容器,以便将photo-sphere-viewer 在页面中显示
<template>
<div id="viewer"></div>
</template>
3.内容加载
编写JS方法
export