axios 里面 then 默认写的function里面没有this,改成箭头函数后就可以用this了


,methods:{
        loadJson:function(){
            //this.jsonTest = "jjj"
          this.$http.get('http://localhost:3003/news/1')
            .then((response) => {
              //console.log(response.data.title);
              this.jsonTest = response.data.title;
              //console.info(this)
            })
            .catch(function (error) {
              console.log(error);
            });
        }
      }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM