class Link{ fn(params){ console.log(params) return this } } class Link{} Link.prototype.fn = function(params){ console.log(params) return this }
第二种方式切不可写成箭头函数形式,是错误的,this指向的问题
class Link{} Link.prototype.fn = (params) => { console.log(params) return this }
this指向window