本文是在下边这篇的基础上做了改动,可以实现拖拽前后图片对比
1.创建组件文件ImageContrast.vue
<template>
<div
class="PictureComparison"
:style="'width:' + width + 'px;height:' + height + 'px'"
>
<div class="before-image" :style="'width:' + x + 'px'" @click.stop="goLeft">
<div :style="'width:' + width + 'px;height:' + height + 'px'">
<slot