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>
     
  • 相关阅读:
    poj_2506_Tiling_201407211555
    poj_2524_Ubiquitous Religions_201407211506
    poj_2586_Y2K Accounting Bug_201407211318
    poj_3006_Dirichlet's Theorem on Arithmetic Progressions_201407041030
    POJ训练计划
    nyoj_10_skiing_201405181748
    nyoj_308_Substring_201405091611
    nyoj_205_求余数_201404271630
    hdu_2082_找单词_201404271536
    nyoj_176_队花的烦恼二_201404262008
  • 原文地址:https://www.cnblogs.com/1609359841qq/p/12092693.html
Copyright © 2011-2022 走看看