vue app启动页

在vue-cli项目中添加页面启动页

<template>
  <div id="app">
  	// 启动页内容开始
    <div class="wrap" v-if="show">
      <div class="pic1">
        <img src="@/assets/images/pic1.png" />
        <img src="@/assets/images/pic2.png" />
        <img src="@/assets/images/pic3.png" />
      </div>
    </div>
    // 启动页内容结束
    
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive" />
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      show: false
    }
  },
  mounted() {
  	//  判断页面是首次加载还是刷新
    if (window.performance.navigation.type === 1) {
      console.log('页面被刷新')
    } else {
       //  首次加载的话显示启动页内容,设置延时器再取消显示
      console.log('首次加载')
      this.show = true
      setTimeout(() => {
        this.show = false
      }, 4000)
    }
  }
}
</script>

<style lang="scss" scoped>
#app {
  height: 100%;
}

//  启动页样式
.wrap {
    width: 100vw;
    height: 100vh;
    background: url('~@/assets/images/bg.png') no-repeat center top #fff;
    background-size: cover;
    box-sizing: border-box;
    overflow: hidden;
    position: fixed;
    z-index: 2;
  }
  .wrap .pic1 {
    position: relative;
    width: 100%;
    top: 48px;
  }
  .pic1 img {
    opacity: 0;
    width: 21%;
    position: absolute;
    left: 48px;
    animation-name: fadeIn; /*动画名称*/
    animation-duration: 1s; /*动画持续时间*/
    animation-iteration-count: 1; /*动画次数*/
    animation-delay: 0s; /*延迟时间*/
    animation-fill-mode: forwards;
  }
  .pic1 img:nth-child(2) {
    left: 128px;
    top: 48px;
    animation-name: fadeIn; /*动画名称*/
    animation-duration: 1s; /*动画持续时间*/
    animation-iteration-count: 1; /*动画次数*/
    animation-delay: 1s; /*延迟时间*/
    animation-fill-mode: forwards;
  }
  .pic1 img:nth-child(3) {
    left: 208px;
    top: 48px;
    animation-name: fadeIn; /*动画名称*/
    animation-duration: 1s; /*动画持续时间*/
    animation-iteration-count: 1; /*动画次数*/
    animation-delay: 2s; /*延迟时间*/
    animation-fill-mode: forwards;
  }
  @keyframes fadeIn {
    0% {
      opacity: 0; /*初始状态 透明度为0*/
    }
    50% {
      opacity: 0; /*中间状态 透明度为0*/
    }
    100% {
      opacity: 1; /*结尾状态 透明度为1*/
    }
  }
</style>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值