• Vue中的组件及缓存 keep-alive


     
     
    <script>
      import { mapState } from "vuex";
      export default {
        
        data() {
            return {
              PlayList: "" 
            };
         },
        
        computed: {
            ...mapState(["Playname"]) //获取vuex中某一条数据
          },
        methods: {
          
          http() {
                let That = this;
                this.axios
                  .get("http:请求的接口=" +this.PlayList)
                  .then(res => {
                    var data = res.data;
                   That.danqu = data;
                   console.log(datadata);
                  });
         
            }
     
        },
         
        mounted() {
            this.PlayList = this.Playname;  //把传过来的值每次先存一下
            this.http();//先调用一次http函数
          },
        activated() {
            if (this.PlayList != this.Vuex获取过来的值) { //判断一下如果获取到的值和上一次获取到的一样就不执行if 如果不一样就执行if
                this.http(); //调用ajax 
                this.PlayList = this.Playname; //把传过来的值给 this.Playname
            }
         }
     
     
      }
    </script>
     
  • 相关阅读:
    cmake使用总结
    Fatal error RC1015: cannot open include file "xxxx.h" vs2008
    可重入函数(转)
    《左耳听风》-ARTS-打卡记录-第十二周
    异常声明
    QString与const char *相互转换
    Qt中使用子线程去关闭弹出框
    什么是反向代理
    【GOJ 3002】颜色
    【GOJ 2296】毛毛虫
  • 原文地址:https://www.cnblogs.com/1609359841qq/p/12092693.html
Copyright © 2020-2023  润新知