zoukankan      html  css  js  c++  java
  • 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>
     
  • 相关阅读:
    C#yield return用法示例
    C#多线程示例
    AspNetCore.Authentication
    C#委托与事件
    按值和按引用传递参数
    基于iView的无限级菜单
    Sortable By Attribute
    未能加载文件或程序集“BLL”或它的某一个依赖项。生成此程序集的运行时比当前加载的运行时新,无法加载此程序集。
    有关导出Excel特殊字符的问题
    openFileDialog的使用
  • 原文地址:https://www.cnblogs.com/1609359841qq/p/12092693.html
Copyright © 2011-2022 走看看