Vue Js get current web protocol : Vue.js provides a global property named `location` which provides access to the current web protocol as well as other useful information such as the URL pathname, hostname, and port number In this tutorial, we’ll look at how to get the current web protocol using native JavaScript and Vue.js.
Vue.js Get Web Protocol Syntax
this.currentProtocol ='Current Protocol: '+ window.location.protocol;
How to get current web protocol from URL in Vue Js?
Vue.js is a JavaScript framework that can be used to retrieve web protocol information from an URL by using window.location.protocol.
Vue js Get Web Protocol from URL | Example
<div id="app">
<button @click="myFunction">Get Protocol</button>
<p>{{currentProtocol}}</p>
</div>
<script type="module">
import { createApp } from 'vue'
createApp({
data()
{
return{
currentProtocol:'',
}
},
methods:{
myFunction(){
this.currentProtocol ='Current Protocol: '+ window.location.protocol;
},
}
}).mount('#app')
</script>