V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  cxyct2  ›  全部回复第 1 页 / 共 1 页
回复总数  4
大家别笑我了,😄
@darksword21 orz 好吧,抱歉了,写了一大堆没有换行
@darksword21 喜欢前端
class A {
      constructor (props) {
        this.props = props
        this.printProps = this.printProps
      }
      printProps = function () {
        return this.props
      }
    }
    (function () {
      const a = new A('haha')
      console.log(a.printProps())
      const fun = a.printProps
      console.log(fun())
    })();
如果不绑 this 的话 a.printProps()不会报错,但是 fun()会报错
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   909 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 19:52 · PVG 03:52 · LAX 12:52 · JFK 15:52
Developed with CodeLauncher
♥ Do have faith in what you're doing.