vue this.$router.go(-1);在移动端失效的问题,重新刷新页面再点击

<template>
  <div class="classify">
    <div style="background-color: #FFFFFF;height: 30px;width: 100%;"></div>
    <!-- <van-nav-bar class="bar" left-arrow :title="$route.meta.title" @click-left="onClickLeft" @click-right="onClickRight" /> -->
    <van-nav-bar @click-left="onClickLeft" :title="title">
      <van-icon class="arrow-left" name="arrow-left" slot="left" />
    </van-nav-bar>
    
    <transition name="fade" appear>
      <router-view></router-view>
    </transition>
    <!-- <floatButton></floatButton> -->
  </div>
</template>

<script>
  import floatButton from '@/components/button/button';
  import {
    Icon
  } from 'vant';
  export default {
    name: 'default',
    components: {
      'floatButton':floatButton,
      [Icon.name]: Icon
    },
    data() {
      return {
        title: ''
      }
    },
    watch: {},
    computed: {},
    beforeCreate() {
      if(!localStorage.getItem('loginNum')){
        localStorage.setItem('loginNum', 1);
        window.location.reload();
      }
    },
    created() {
      this.title = this.$route.query.title;
    },
    methods: {
      onClickLeft() {
        this.$router.go(-1);
        // if(!localStorage.getItem('loginNum')){
        //   localStorage.setItem('loginNum', 1);
        //   this.$router.go(-1);
        //   window.location.reload();
        // }else{
        //   this.$router.go(-1);
        // }
      }
    }
  }
</script>

<style lang="scss" scoped>
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity .5s;
  }

  .fade-enter,
  .fade-leave-to

  /* .fade-leave-active below version 2.1.8 */
    {
    opacity: 0;
  }

  .arrow-left {
    color: #898989;
    font-size: 20px;
  }

  .classify {
    position: absolute;
    width: 100%;
    min-height: 100%;
    background-color: #0189FF;
  }
</style>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值