账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    为什么析构url对象会出现意想不到的结果
    16
    0

    在学习Node.js的过程中,想要复制一个url对象引用,结果不尽人意,细节如下:

    console.log(new URL('file://'))
    
    // URL {
    //   href: 'file:///',
    //   origin: 'null',
    //   protocol: 'file:',
    //   username: '',
    //   password: '',
    //   host: '',
    //   hostname: '',
    //   port: '',
    //   pathname: '/',
    //   search: '',
    //   searchParams: URLSearchParams {},
    //   hash: '' }
    

    而析构重建确实这样的对象:

    console.log({ ...new URL('file://') })
    
    // { [Symbol(context)]:
    //   URLContext {
    //     flags: 400,
    //     scheme: 'file:',
    //     username: '',
    //     password: '',
    //     host: '',
    //     port: null,
    //     path: [ '' ],
    //     query: null,
    //     fragment: null },
    //  [Symbol(query)]: URLSearchParams {} }
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 冷羽无情 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部