- Node.js 教程
- Node.js - 首頁
- Node.js - 簡介
- Node.js - 環境搭建
- Node.js - 第一個應用程式
- Node.js - REPL 終端
- Node.js - 命令列選項
- Node.js - 包管理器 (NPM)
- Node.js - 回撥函式概念
- Node.js - 上傳檔案
- Node.js - 傳送郵件
- Node.js - 事件
- Node.js - 事件迴圈
- Node.js - 事件發射器
- Node.js - 偵錯程式
- Node.js - 全域性物件
- Node.js - 控制檯
- Node.js - 程序
- Node.js - 應用程式擴充套件
- Node.js - 打包
- Node.js - Express 框架
- Node.js - RESTful API
- Node.js - 緩衝區
- Node.js - 流
- Node.js - 檔案系統
- Node.js MySQL
- Node.js - MySQL 快速入門
- Node.js - MySQL 建立資料庫
- Node.js - MySQL 建立表
- Node.js - MySQL 插入資料
- Node.js - MySQL 查詢資料
- Node.js - MySQL 條件查詢
- Node.js - MySQL 排序
- Node.js - MySQL 刪除資料
- Node.js - MySQL 更新資料
- Node.js - MySQL 連線查詢
- Node.js MongoDB
- Node.js - MongoDB 快速入門
- Node.js - MongoDB 建立資料庫
- Node.js - MongoDB 建立集合
- Node.js - MongoDB 插入資料
- Node.js - MongoDB 查詢資料
- Node.js - MongoDB 查詢
- Node.js - MongoDB 排序
- Node.js - MongoDB 刪除資料
- Node.js - MongoDB 更新資料
- Node.js - MongoDB 資料限制
- Node.js - MongoDB 連線查詢
- Node.js 模組
- Node.js - 模組
- Node.js - 內建模組
- Node.js - 實用工具模組
- Node.js - Web 模組
- Node.js 有用資源
- Node.js - 快速指南
- Node.js - 有用資源
- Node.js - 討論
NodeJS - urlObject.href 屬性
NodeJS urlObject.href 屬性 指定了已解析的完整小寫 URL 字串,包含協議和主機部分。如果 URL 字串包含大寫字母,href 屬性會將其轉換為小寫。
例如,對於 URL “https://user:pass@SITE.com/pa/th?=val#hash”,hash 屬性的返回值將是 “https://user:pass@Site.com/pa/th?=val#hash”。
語法
以下是 NodeJS urlObject.href 屬性 的語法
urlObject.href
引數
此屬性不接受任何引數。
返回值
此屬性檢索已解析的完整 URL 字串,包括已轉換為小寫的協議和主機部分。
示例
以下示例演示了 NodeJS urlObject.href 屬性的用法。
const url = require('url');
let address = 'https://user:pass@tutorialspoint.com/pa/th?=val#hashh';
let result = url.parse(address, true);
console.log(result.href);
輸出
從下面的輸出中可以看到,NodeJS href 屬性檢索了完整的 URL 字串,包括協議和主機部分。
https://user:pass@tutorialspoint.com/pa/th?=val#hashh
示例
如果我們不解析指定的 URL,auth 屬性將為 undefined。
我們嘗試在不解析的情況下使用 href 屬性獲取完整的 URL 字串。
const url = require('url');
let address = 'https://user:pass@tutorialspoint.com/pa/th?=val#hashh';
console.log(address.href);
輸出
從下面的輸出中可以看到,href 屬性為 undefined。
undefined
nodejs_url_module.htm
廣告
