Loner__ 2019-12-10 11:21 采纳率: 0%
浏览 1266

在使用vue-preview缩略图时src图太大了,怎么调小?

最近在学习vue的一个移动商城项目,但是视频已经是两年前的了,许多地方都搞不明白。在学习使用vue-preview缩略图时,我的src图片和msrc图片差不多大,我不明白这是为什么,还要如何才能让他达到理想的缩略图效果?
代码如下:

<template>
  <div class="photoinfo-container">
    <h3>{{ photoinfo.title }}</h3>
    <p class="subtitle">
      <span>发表时间:{{ photoinfo.add_time | dateFormat }}</span>
      <span>点击:{{ photoinfo.click }}次</span>
    </p>

    <hr>

    <!-- 缩略图区域 -->
    <div class="thumbs">
     <vue-preview :slides="slide1" @close="handleClose" tag="img" height="100px"></vue-preview>
    </div>
    <!-- 文字内容区域 -->
    <div class="content" v-html="photoinfo.content" ></div>

    <!-- 放置一个现成的 评论子组件 -->
    <cmt-box :id="id"></cmt-box>
  </div>
</template>

<script>
// 1. 导入评论子组件
import comment from "../subcomponents/comment.vue";

export default {
  data() {
    return {
      id: this.$route.params.id, // 从路由中获取到的 图片Id
      photoinfo: {}, // 图片详情
      slide1: [],

    };
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();

  },
  methods: {
    getPhotoInfo() {
      // 获取图片的详情
      this.$http.get("api/getimageInfo/" + this.id).then(result => {
        if (result.body.status === 0) {
          this.photoinfo = result.body.message[0];
        }
      });
    },
    getThumbs() {
      // 获取缩略图
      this.$http.get("api/getthumimages/" + this.id)
      .then(result => {
        if (result.body.status === 0) {
          // 循环每个图片数据,补全图片的宽和高
          result.body.message.forEach(item => {
            item.w = 600;
            item.h = 400;
            item.msrc = item.src;
          });
          // 把完整的数据保存到 slide1 中
          this.slide1 = result.body.message;
        }
      })
      .catch(error => {
        console.log(error);
        Toast({
        message: "获取缩略图图片失败..."
        });
        });
    },
    handleClose () {
        console.log('close event')
      }
  },
  components: {
    // 注册 评论子组件
    "cmt-box": comment
  }
};
</script>

<style lang="scss" scoped>
.photoinfo-container {
  padding: 3px;
  h3 {
    color: #26a2ff;
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }

  .content {
    font-size: 13px;
    line-height: 30px;
  }

  .thumbs{
    img{
      margin: 10px;
      box-shadow: 0 0 8px #999;

    }
  }
}

</style>

我的效果图:
图片说明
图片说明

应达到的效果图:图片说明

  • 写回答

1条回答 默认 最新

  • console.log( ) 2019-12-10 14:54
    关注

    对缩略图的高改变试试 不行就设置缩略图的css

    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果