vue实现点击下载图片

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29918313/article/details/82496499
​<el-table-column label='缩略图' width='100'>
   <template slot-scope='scope'>
       <a :href="scope.row.url" download="">
          <img :src='scope.row.url' class="img-circle" width="35px" style="" />
       </a>
    </template>
</el-table-column>

主要实现的功能是,vue开发的页面中,点击图片,直接将该图片保存到本地,是用a标签实现;

不过这里需要注意的是,该方式只支持火狐与谷歌浏览器;

另外在代码实现的过程中应注意href与src中都是图片地址,且要保持一致;href前要加:实现动态绑定;download里的属性值是下载的文件名,若为空,则文件名为href中的图片名称。 ​

猜你喜欢

转载自blog.csdn.net/qq_29918313/article/details/82496499