vue中 方法名:function() {} 和 方法名() {}区别

区别就是前者是ES5写法,后者是ES6写法

methods:{
    //ES5
    getData: function (){

    }
    //ES6
    getData() {
        this.axios({
        method: 'get',
        url: '/data.json'
        }).then(function (repos) {
          console.log(repos);
        }).catch(function (error) {
          console.log(error);
        });
    }
}
全部评论

相关推荐

点赞 评论 收藏
分享
12-20 13:19
已编辑
曲阜师范大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务