vue中封装运动插件

运动插件

<template>
  <transition>
    <slot></slot>
  </transition>
</template>

<script>
export default {
  name: 'Fade'
}
</script>

<style scoped lang="stylus">
  .v-enter, .v-leave-to
    opacity 0
  .v-enter-active, .v-leave-active
    transition opacity .5s
</style>

使用该插件的页面

<template>
  <div>
    <detail-banner :sightName="sightName" :bannerImg="bannerImg" :imgLen="imgLen" @show="showImgEvent"/>
    <detail-header v-if="!showImg"/>
    <!-- 使用运动效果 -->
    <fade-animation>
      <common-gallary v-if="showImg" :imgs="imgs" @show="showImgEvent"/>
    </fade-animation>
    <div class="container" v-if="!showImg">
      <detail-list :list="list"/>
    </div>
  </div>
</template>

<script>
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
import CommonGallary from 'common/gallary/Gallary'
// 引入运动组件
import FadeAnimation from 'common/fade/Fade'
import axios from 'axios'
export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    CommonGallary,
    DetailList,
    FadeAnimation
  },
  data () {
    return {
      showImg: false,
      imgs: [ ],
      list: [ ],
      bannerImg: '',
      sightName: '',
      imgLen: 0
    }
  },
  methods: {
    showImgEvent (status) {
      this.showImg = status
    },
    getDetailInfo () {
      axios.get('/api/detail.json', {
        params: {
          id: this.$route.params.id
        }
      }).then(this.getDetailInfoSucc)
    },
    getDetailInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.imgs = data.gallaryImgs
        this.list = data.categoryList
        this.bannerImg = data.bannerImg
        this.sightName = data.sightName
        this.imgLen = data.gallaryImgs.length
      }
    }
  },
  mounted () {
    this.getDetailInfo()
  }
}
</script>

<style lang="stylus" scoped>
  .container
    height 2000px
</style>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值