alfhen / vue-cookie

A Vue.js plugin for manipulating cookies
MIT License
822 stars 74 forks source link

Why plugin? #14

Closed jiv-e closed 7 years ago

jiv-e commented 7 years ago

I find this project interesting. Can you explain why not to use tiny-cookie directly? What are the benefits of using Vue plugin?

It would be great if the answers could be added to the README.

janat08 commented 7 years ago

I guess to render cookies or use them in template tags, since it doesn't appear to have global scope or what.

jiv-e commented 7 years ago

Why not import tiny-cookie directly to your component where needed like this?

<script>
  import cookie from 'tiny-cookie'

  export default {
    name: 'my-component',
    methods: {
      setCookie() {
        cookie.set('test', 'Hello world!', 1);
      },
    ...
janat08 commented 7 years ago

try