在vue方法中使用setInterval时数据变量未定义

时间:2020-04-13 11:04:51

标签: javascript vue.js vuejs2 vue-component

当我从vue数据中获取数据变量时,未定义变量如何在vue方法中实时交换变量

export default {
      name: 'Chart',
      components: {
     },
     data(){
         return {
             firstUpdateTime:0,
             price:[],
             timeLable:[],
             maxPrice: 20000,
         }
     },
     methods:{

         calculateChart : function(){
             var a = 300;
             setInterval(() => 

               this.firstUpdateTime ++;
               a--;

            );}, 30000);


         }
     },

}

0 个答案:

没有答案