如果想從頭學起Cypress,可以看下面的系列文章哦
https://www.cnblogs.com/poloyy/category/1768839.html
作用
- 獲取頁面當前的 url 的哈希值
- 等價於 cy.location('hash')
語法格式
cy.hash()
cy.hash(options)
options:只有 timeout 和 log,不再展開講了
正確寫法
cy.hash()
實際栗子
html 代碼
<ul id="users"> <li> <a href="#/users/8fc45b67-d2e5-465a-b822-b281d9c8e4d1">Fred</a> </li> </ul>
測試文件代碼

測試結果

總結
感覺這方法應該用的不多,如果是普通的鏈接,是不會返回哈希值的
結尾
我的博客即將同步至騰訊雲+社區,邀請大家一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=12vd92hxgwgj1
