JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

奇怪的this

发布时间 2023-04-20 16:21:27作者: 黄燃
        var obj = {
            id: "awesome",
            cool: () => {  // 向上寻找this,js会自动为function的作用域创建this指向function本身,箭头函数除外
                console.log(this.id);
            }
        };
        var id = "not awesome";
        obj.cool();  // not awesome
        setTimeout(obj.cool, 1000);  // not awesome

  

    本栏目推荐文章
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
  • vue报错:Module parse failed: Unexpected token (5:2) You may need an appropriate loader to handle this file type.
  • About this page
  • JavaScript this 绑定详解
  • JavaScript this 绑定详解
  • react 事件函数中 this 绑定问题
  • mysql--You must reset your password using ALTER USER statement before executing this statement
  • keil 工程编译报错browse infomation of one or more files is not available: ……Doing a project rebuild might fix this.
  • 修改账户密码时提示 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 错误
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们