location protocol 属性(http、https)

xiaoxiao2025-08-18  35

location protocol 属性

protocol 属性是一个可读可写的字符串,可设置或返回当前 URL 的协议。

语法

location.protocol

location.protocol //"http:"
使用场景

vue配置api地址的时候,根据 location.protocol 的地址切换http和https,避免在api地址切换成https的时候,出现请求报错。

转载请注明原文地址: https://www.6miu.com/read-5035001.html

最新回复(0)