alfhen / vue-cookie

A Vue.js plugin for manipulating cookies
MIT License
821 stars 72 forks source link

!!cookie as false won't work in lifecycle hook #16

Closed janat08 closed 7 years ago

janat08 commented 7 years ago

for some reason it will produce true value if false with double ! to convert null value of cookie not created.

janat08 commented 7 years ago

using base library there're no bugs.

alfhen commented 7 years ago

@janat08 Could you please elaborate? ie. show some example code a use case where the problem occurs.

janat08 commented 7 years ago

mounted: function () { this.romanized = !(!(Cookie.get('romanized'))) console.log('romanized', this.romanized, !!Cookie.get('romanize')) },

alfhen commented 7 years ago

Hmm, its seems you are using the Global Cookie function provided by tiny-cookie try doing

this.$cookie.get('romanized');
janat08 commented 7 years ago

No, using your package for global variant is what will fail

On Tue, Apr 11, 2017 at 11:59 PM, Alf notifications@github.com wrote:

Hmm, its seems you are using the Global Cookie function provided by tiny-cookie try doing

this.$cookie.get('romanized');

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alfhen/vue-cookie/issues/16#issuecomment-293347410, or mute the thread https://github.com/notifications/unsubscribe-auth/AKz-gT3r27uONNtp5ou_CNEmIbxJbQKoks5ru7-CgaJpZM4M4Brp .

alfhen commented 7 years ago

@janat08, If you want to use the global Cookie.get() function, then I suggest that you use the tiny-cookie package directly in your project rather than relying on this package. This package supports two ways of interacting with cookies through either this.$cookie or Vue.cookie as described in the documentation.

janat08 commented 7 years ago

would you try !!this.$cookie.get('stuf') yourself

On Fri, Apr 21, 2017 at 2:31 PM, Alf notifications@github.com wrote:

Closed #16 https://github.com/alfhen/vue-cookie/issues/16.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alfhen/vue-cookie/issues/16#event-1052043221, or mute the thread https://github.com/notifications/unsubscribe-auth/AKz-gU0IvTsqDOWx9J9phurgmssWqohgks5ryGl9gaJpZM4M4Brp .