首页 > 解决方案 > 属性或方法“LIVE”未在实例上定义,但在渲染期间被引用

问题描述

我在 laravel 中使用 vue.js 来更新我的记分卡,一切正常,直到我不应用检查只更新实时比赛的记分卡。这是我的代码。

<script>
export default {
  data: function(){
    return {
      scoreCard: "",
      play: ""
    };
  },
  props: ["live_check","playingteamid","series_id", "match_id"],
  methods: {
    getScoreCard: function(s, m, p) {
      fetch(
        "https://api_Request" +
          s +
          "/" +
          m +
          "?format=json"
      )
        .then(response => response.json())
        .then(data => {
            if(data.fullScorecard.innings[0].team.id==p){
                this.play = data.fullScorecard.innings[0];
            }else if(typeof data.fullScorecard.innings[1] !='undefined'){
              if(data.fullScorecard.innings[1].team.id==p){
              this.play = data.fullScorecard.innings[1];
              }
          }
        });
    }
  },
  created: function(){
      this.getScoreCard(this.series_id,this.match_id,this.playingteamid);
      if(this.live_check=='LIVE'){ //This Live check is showing error

          setInterval(function(){
              this.getScoreCard(this.series_id,this.match_id,this.playingteamid);
          }.bind(this),3000)
      }else{
          console.log('Match is not Live');
      }
  }
};
</script>

vue.js:634 [Vue 警告]:属性或方法“LIVE”未在实例上定义,但在渲染期间被引用。通过初始化该属性,确保该属性是反应性的,无论是在数据选项中,还是对于基于类的组件。请参阅:https ://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties 。(在发现 )

标签: javascriptvue.js

解决方案


推荐阅读