3.2.1 • Published 2 years ago

vue-sync v3.2.1

Weekly downloads
234
License
WTFPL
Repository
github
Last release
2 years ago

vue-sync

NOTE: Check out nuxt-url-sync to use it with SSR

Sync Vue Component state with browser URL params

Makes for easy bookmarking and sharing of vue state using the browser URL, also works server-side when using vue-router.

Install

With NPM

$ npm install --save vue-sync
VueSync = require('vue-sync')
Vue.use(VueSync)

Usage

Sync Vue state with parameters in the browser url. Makes for very easy bookmarking and sharing of vue state.

The below example will sync the value of currentPage with the URL parameter value page.

new Vue({
  data: function() {
    return {
      currentPage: this.currentPage || 'users' // initialize this component data with the url param or set 'users' as a default
    }
  },
  // sync with URL `http://example.com/?page=amazing-title`
  url: {
    currentPage: 'page'
  }
})

If you don't want to add a browser history entry when the value changes, use the noHistory option.

new Vue({
  data: function() {
    return {
      currentPage: this.currentPage || 'users'
    }
  },
  url: {
    currentPage: {
      param: 'page',
      noHistory: true
    }
  }
})
3.2.1

2 years ago

3.2.0

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago