Vue.js check Cookie is Enabled
We can use native JavaScript navigator cookieEnabled property to check whether the cookie is enabled or not on browser. Here in this tutorial, we are going to explain how you can use navigator cookieEnabled property in vue.js. You can also use our online editor to edit and run the code online.
Vue.js check Cookie is Enabled Example
You can check whether cookie is enabled or not simply as below-
Example:
<div id="app"> <p>Result = {{result}}</p> <button @click="myFunction()">Click Me</button> </div> <script> new Vue({ el: '#app', data: { result: '' }, methods:{ myFunction: function () { if(navigator.cookieEnabled){ this.result = "Cookie Is Enabled"; }else{ this.result = "Cookie Is Disabled"; } } } }); </script> |
Output of above example-
Advertisements