Accessing props in vue component data function

前端 未结 5 789
醉话见心
醉话见心 2021-02-03 16:59

I am passing a props to a component:





        
5条回答
  •  伪装坚强ぢ
    2021-02-03 17:33

    From the data() method, you can reference the component's properties using this.

    So in your case:

    data: function() {
      var theData = {
        somevar: this.messageId,
        // other object attributes
      }
    
      return theData;
    }
    

提交回复
热议问题