下面是渐进式图片的基础用法。
<template> <div class="t-progressive-image-area"> <div class="btn-area"> <button class="show-btn" @click="showImage">显示图片</button> <button class="hide-btn" @click="hideImage">隐藏图片</button> </div> <div class="text-area" v-if="animationProgressiveShow"> <as-animation-progressive-image src="https://images.pexels.com/photos/33109/fall-autumn-red-season.jpg?fit=crop&crop=entropy&w=3456&h=2304" placeholder="https://images.pexels.com/photos/33109/fall-autumn-red-season.jpg?w=100" @load="loadImage"> </as-animation-progressive-image> </div> </div> </template> <script> export default { name: "t-progressive-image", data(){ return{ animationProgressiveShow:false, } }, methods:{ showImage(){ this.animationProgressiveShow=true; }, hideImage(){ this.animationProgressiveShow=false; }, loadImage(){ console.log("图片加载完成") }, } } </script> <style> .t-progressive-image-area .btn-area{ width: 100%; height: 60px; display: flex; flex-direction: row; align-items: center; } .t-progressive-image-area .btn-area button{ background-color: dodgerblue; border-radius: 5px; width: 100px; height: 40px; outline: none; border: none; color: #ffffff; } .t-progressive-image-area .btn-area .hide-btn{ margin-left: 20px; } .t-progressive-image-area .text-area{ width: 100%; height: 340px; } @media screen and (max-width: 480px) { .t-progressive-image-area .text-area{ height: 180px; } } </style>
← 视差滚动 海浪进度条 →