使用vue一个组件vue-directive-image-previewer
A Vue.js project for tag img, click img to zoom out to full screen.
安装vue-directive-image-previewer
命令行引入组件
npm install vue-directive-image-previewer -D
main.js添加引用
import VueDirectiveImagePreviewer from 'vue-directive-image-previewer' import 'vue-directive-image-previewer/dist/assets/style.css' Vue.use(VueDirectiveImagePreviewer)
最后可以直接在标签内使用
<template> <div> <img v-image-preview src="picture-url"/> </div> </template>