vue中使用transition做动画

Posted fkcqwq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue中使用transition做动画相关的知识,希望对你有一定的参考价值。

<template>
  <div class="casehistory">
    <jzrlist :isup="isup" :lastOrder="lastOrder" :djs="djs" @getjzrinfo="getjzrinfo"></jzrlist>
    <div class="classCaseHsitoryBox" :style="{height: ‘calc(100vh - ‘ + chagePatient + ‘)‘}">
      <div class="contentBox">
        <!-- 无病历信息 -->
        <div style="display:none" class="noMsg">
          <img src="../../assets/img/no_case.png" alt />
          <p>您暂无病历信息~</p>
        </div>
        <!-- 有就诊人且有就诊人病历信息 -->
        <div class="havePatient">
          <div class="time">2019-05-01 星期三</div>
          <!-- 病历信息(检查单) -->
          <div class="reportBox reportCensor">
            <h4>病历信息(检查单)</h4>
            <ul>
              <li>
                <img
                  src="https://file.syrjia.com/uploadFiles/uploadImgs/20200528/20200528120247.png"
                  alt
                />
              </li>
              <li>
                <img
                  src="https://file.syrjia.com/uploadFiles/uploadImgs/20200528/20200528120247.png"
                  alt
                />
              </li>
              <li>
                <img
                  src="https://file.syrjia.com/uploadFiles/uploadImgs/20200528/20200528120247.png"
                  alt
                />
              </li>
              <li>
                <img
                  src="https://file.syrjia.com/uploadFiles/uploadImgs/20200528/20200528120247.png"
                  alt
                />
              </li>
            </ul>
          </div>
          <!-- 病历信息(处方单) -->
          <div class="reportBox reportPrescription">
            <h4>病历信息(处方)</h4>
           
              <ul>
                <img
                  class="msgMor"
                  @click=" type ? type = false : type =true"
                  src="../../assets/img/msgMore.png"
                  alt
                />
                 <transition-group name="slide">
                  <!-- type代表数据的长度如果是3为真,为6(需要改为数据的.length)为假  -->
                <li class="more" v-for="(n,index) in 6" v-if="index < (!type ? 3 : 6)" :key="index">
                  <img
                    src="https://file.syrjia.com/uploadFiles/uploadImgs/20200528/20200528120247.png"
                    alt
                  />
                </li>
                 </transition-group>
              </ul>
          
          </div>
          <div class="remark">
            <h4>备注</h4>
            <p>备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注</p>
          </div>
          <div class="time">2019-05-01 星期三</div>
          <div class="doctor">
            <div class="docPro">
              <img
                src="https://file.syrjia.com/uploadFiles/uploadImgs/20200528/20200528120247.png"
                alt
              />
              <h5>张萌医生</h5>
            </div>
            <h4>诊断:腰间盘突出</h4>
            <p>点此查看为您开具的调理方案>></p>
          </div>
        </div>
        <!-- 无就诊人 ——创建就诊人-->
        <div style="display:none" class="createPaitent">
          <p>您还没有创建就诊人</p>
          <span>点击创建</span>
        </div>
        <!-- 无就诊人——填写就诊人信息 -->
        <div style="display:none" class="fillInMsg">
          <div class="tip">请添加就诊人,和我建立联系</div>
          <peopleInfo :isDescript="true" ref="peopleInfo" @getData="getData"></peopleInfo>
        </div>

        <!-- 更新病历信息按钮  -->
        <footer>
          <div class="updateMsg">更新病历信息</div>
          <div class="createSubmit">提交</div>
        </footer>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  name: "casehistory",
  data() {
    return {
      chagePatient: "1.9rem",
      isup: false,
      lastOrder: {},
      djs: "",
      jzrinfo: "",
      type: false
    };
  },
  mounted() {},
  methods: {
    getjzrinfo(data) {
      this.jzrinfo = data;
    },
    getData(data) {
      //获取创建就诊人时的信息
      console.log(data);
      this.form = data;
    }
  },
  components: {
    jzrlist: resolve => require(["@/components/doctor/jzrList"], resolve),
    peopleInfo: resolve =>
      require(["@/components/people/people_info"], resolve),
    [Toast.name]: Toast
  }
};
</script>

<style rel=‘stylesheet/scss‘ lang=‘scss‘ scoped>
.slide-enter-active{
 transition:all .5s linear;
 }
 .slide-leave-active{
  transition:all .5s linear;
 }
 .slide-enter{
   transform: translateY(-10%);
  // opacity: 0;
 }
 .slide-leave-to{
  // opacity: 0;
  transform: translateY(-10%);
 }

img {
  max-width: 100%;
}
.casehistory {
  background: #fff;
}
.classCaseHsitoryBox {
  margin-top: 0.9rem;
  .contentBox {
    .havePatient {
      .time {
        background-color: #f5f5f5;
        height: 0.7rem;
        line-height: 0.7rem;
        padding: 0 0.3rem;
        font-size: 0.26rem;
      }
      .reportBox {
        padding: 0 0.3rem;
        h4 {
          font-size: 0.28rem;
          padding: 0.38rem 0;
        }
        ul {
          overflow: hidden;
          border-bottom: 1px solid #eeeeee;
          padding-bottom: 0.1rem;
          position: relative;
          .msgMor {
            width: 0.41rem;
            position: absolute;
            right: 0.33rem;
            top: 0.65rem;
          }
          li {
            width: 2.1rem;
            height: 2.1rem;
            border: 1px solid #e6e7ec;
            box-shadow: 0px 0px 0.1rem 0px rgba(182, 168, 167, 0.23);
            border-radius: 0.1rem;
            overflow: hidden;
            margin: 0 0.29rem 0.29rem 0;
            float: left;
            &:nth-of-type(3n) {
              margin-right: 0;
            }
            &.more {
              width: 1.7rem;
              height: 1.7rem;
            }
          }
        }
      }
      .remark {
        padding: 0 0.3rem;
        h4 {
          font-size: 0.28rem;
          margin: 0.38rem 0 0.25rem 0;
        }
        p {
          line-height: 0.45rem;
          font-size: 0.3rem;
          margin-bottom: 0.45rem;
        }
      }
      .doctor {
        padding: 0.4rem 0.3rem;
        margin-bottom: 1rem;
        font-size: 0.3rem;
        .docPro {
          display: flex;
          align-items: center;
          img {
            width: 0.64rem;
            height: 0.64rem;
            border-radius: 50%;
          }
          h5 {
            margin-left: 0.26rem;
          }
        }
        h4 {
          margin: 0.28rem 0;
        }
        p {
          color: #8f5f3b;
        }
      }
    }
    // 无病历信息
    .noMsg {
      text-align: center;
      img {
        margin: 2.88rem auto 0;
        font-size: 0.32rem;
        color: #666666;
        width: 2.64rem;
        overflow: hidden;
        text-align: center;
      }
      p {
        text-align: center;
        font-size: 0.28rem;
        color: #666666;
        margin-top: 0.6rem;
      }
    }
    //无就诊人 ——创建
    .createPaitent {
      padding: 0 0.3rem;
      height: 1rem;
      font-size: 0.3rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-top: 1px solid #eeeeee;
      span {
        width: 1.28rem;
        height: 0.5rem;
        border-radius: 0.25rem;
        background-color: #da0428;
        font-size: 0.24rem;
        color: #fff;
        text-align: center;
        line-height: 0.5rem;
      }
    }
    //无就诊人——填写信息
    .fillInMsg {
      .tip {
        height: 0.9rem;
        background-color: #f3f3f3;
        font-size: 0.26rem;
        color: #666;
        padding: 0 0.3rem;
        line-height: 0.9rem;
      }
    }
  }
  footer {
    .createSubmit,
    .updateMsg {
      height: 1rem;
      color: #fff;
      text-align: center;
      line-height: 1rem;
      font-size: 0.32rem;
      position: fixed;
      bottom: 0;
      width: 100%;
    }
    .updateMsg {
      background-color: #da0428;
    }
    .createSubmit {
      background-color: #e4e4e4;
    }
  }
}
</style>

  

以上是关于vue中使用transition做动画的主要内容,如果未能解决你的问题,请参考以下文章

vue的transition-group 下面每个元素分别执行动画

vue3 之 Transition && 各种动画实现,一文让你会动画

vue的动画组件(transition)

使用 CSS 和 jQuery 创建自己的 Vue <transition-group> 动画

vue移动端转场动画

vue移动端转场动画