[Vuejs]-Unexpected behaviour of v-bind:class and cookies (Vue js)

0👍

Try parsing the string value to Boolean using JSON:

var cookieCheck = $cookies.get('isDark');  

if (cookieCheck === 'undefined') {
    cookieCheck = false;
    console.log('COOKIE DOESNT EXIST');
} else {
    console.log("COOKIE EXISTS")
    // if it exists parse the value
    cookieCheck = JSON.parse(cookieCheck)
    // Check its type
    console.log(typeof cookieCheck)
    // >> boolean
}

Leave a comment