vue-route-sync-plugin
v1.0.0-beta.13
Published
![Travis (.com)](https://img.shields.io/travis/com/teeeemoji/vue-route-sync-mixin) ![Codecov](https://img.shields.io/coveralls/expressjs/express/master.svg) ![npm](https://img.shields.io/npm/v/vue-route-sync-plugin) ![npm](https://img.shields.io/npm/dy
Downloads
19
Readme
vue-route-sync-plugin
What is vue-route-sync-plugin
vue-route-sync-plugin is a Vue implementation of DeepLinking solution. It uses a simple way to implementing "two-way binding" between url query and vm data.
It's awesome that we can synchronize the page state to the url in real time, so we can share the page state by sharing the URL, like share the search results on page 4 of the search keyword teeeemoji.
Features
- :tada: The implementation of url and data two-way binding, this is really exciting
- :sparkles: Non-invasive to legacy project logic and components
- :chart_with_upwards_trend: Simple configuration, faster to use
- :rocket: Only depends on the vue-router
- :fire: More features is waiting for you to discover...
Installation
$ npm install vue-route-sync-plugin
Usage
Single File Component Example:
- main.js
import {routerSyncPlugin} from 'vue-route-sync-plugin'
Vue.use(routerSyncPlugin.initPlugin({
ps:"pagination.pageSize",
pn:"pagination.pageNum"
}))
- component
<script>
export default {
data() {
return {
pagination: {
pageSize: 10,
pageNum: 1
}
};
}
};
</script>
API
createRouteSyncMixin
A series of mixins is automatically generated for the url synchronization function
Parameters
options
{{}} A map of $route.query keys to vm's property pathoptions.KeyOfOptions
{string} Key of options is the value key on url query string, and its also the key in vm.$routeoptions.ValueOfOptions
{string} Value of options is a path to find the actual value in vm
Returns {} A series of mixins
processEscapeStr2Value
process escape string to value with its data type
Parameters
str
{string}
Returns (string | any | undefined | number)
processValue2EscapeStr
process value to escape string
Parameters
val
{any}
Returns string
TODO
- write demo
License
This project is licensed under the MIT license.