How to pass data from Vue instance to component

前端 未结 1 324
忘了有多久
忘了有多久 2021-01-14 08:05

First I must say I have spent hours on this so if I have overlooked something stupidly simple then I do apologise.

I am trying to get one component to talk to anothe

1条回答
  •  花落未央
    2021-01-14 08:37

    It seems this is happening because your this is not pointing to correct scope in fetchModelsByMake method. scope of this will change inside a 'this.$http' call, so you just have to do something like following:

            fetchModelsByMake: function() {
                var self = this
                this.$http.get('/api/make/models/' + this.make ).then(
                    function (models) {
                        self.models = models.body;
    

    // console.log('MODEL', this.model); }, function (error) { // handle error } );

    You can also have a look at my similar answer here.

    0 讨论(0)
提交回复
热议问题