JavaScript之链式调用this箭头函数

Posted web半晨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript之链式调用this箭头函数相关的知识,希望对你有一定的参考价值。

var sched = 
    a: function() 
        console.log('a');
        return this;
    ,
    b: function() 
        console.log('b');
        return this;
    ,
    c: () => 
        console.log('c');
        return this;
    ,
    d: () => 
        console.log('d');
        return this;
    ,
;

sched.a().b().c().d();
// 调用d的时候报错
// 因为在箭头函数中this的固定指向
// Uncaught TypeError: sched.a(...).b(...).c(...).d is not a function

以上是关于JavaScript之链式调用this箭头函数的主要内容,如果未能解决你的问题,请参考以下文章