const. 2019-04-25 10:00 采纳率: 50%
浏览 3456

vue 点击商品跳转详情页,每次进去都要刷新数据才更新,求大神帮解决

小白求组,试了keepAlive的方法也不行,求大神帮看看

APP.vue

    <keep-alive>
      <router-view></router-view>
    </keep-alive>

router

      {
        path: '/goods/:goodId',
        name: "goodsdetail",
        component: Goods,
        meta:{keepAlive:false}
      },

商品页

<template>
  <a class="recommend-item" @click.stop="$router.push({name:'goodsdetail', params:{ goodId:rec.goods_id }})">
    <img v-lazy="rec.thumb_url" alt="" width="100%" v-if="rec.thumb_url">
    <h4 class="item-title">{{rec.short_name}}</h4>
    <div class="item-bottom">
      <span class="item-price">¥{{rec.price / 100}}</span>
      <span class="item-sales">{{rec.sales_tip}}</span>
      <button class="item-btn" @click="clickCellBtn(rec)"><i class="icon-6"></i></button>
    </div>
    </a>
</template>

商品详情页

    export default {
      name: "GoodsDetail",
      data() {
        return {
          id: this.$route.params.goodId,
        }
      },
      computed: {
        ...mapState(['goods_detail'])
      },
      activated() {
        this.fetchData();
      },
      watch: {
        goods_detail() {
          this.$nextTick(() => {
            // 创建swiper的实例
            new Swiper('.swiper-container', {
              autoplay: true,//等同于以下设置
              loop: true,
              // 如果需要分页器
              pagination: {
                el: '.swiper-pagination',
              }
            });
          });
        },
      },
      methods:{
        fetchData(){
          let goods_id = this.id;
          this.$store.dispatch('getDetail',{goods_id});

        }
      },
    }
</script>
  • 写回答

1条回答 默认 最新

  • Q_N 2019-10-08 16:11
    关注

    This. $forceUpdate()

    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题