vue 移动端项目 (反馈面板 不感兴趣功能实现)

实现效果及要求:

点击不感兴趣能够提示是否成功

通过if 判断全等于“不感兴趣”的时候,让其里边的方法 利用子传父的方法,在AeitivleItem.vue 里通过this.$emit的方式传参,并且传id

 在父组件用于接收子组件 传值

 在api 里请求数据

 在Ariticlelist.vue 引入api 的方法

 在methods里进行请求数据

   //顶部刷新事件方法
    async onRefresh() {
      // 目标: list 数组 清空,来一份新的数据

      this.list = [];
      this.theTime = new Date().getTime();

      this.getAriticleListFn();
    },
    // 反馈, 不感兴趣
    async disLikeFn(id) {
      console.log(id);
      const res5 = await dislikeArticleAPI({ artId: id });
      console.log("反馈", res5);
      // 成功通知
Notify({ type: 'success', message: '反馈成功' });
    },
  },

无论请求数据成功或者失败都要进行提示引入Notify组件

import { Notify } from 'vant';

最后在methods 里进行提示即可!!!

猜你喜欢

转载自blog.csdn.net/weixin_59519449/article/details/123946957
今日推荐