1. vue-route-sync-mixin
A DeepLinking solution implementation in Vue
vue-route-sync-mixin
Package: vue-route-sync-mixin
Created by: teeeemoji
Last modified: Mon, 23 May 2022 18:17:17 GMT
Version: 1.0.3
License: MIT
Downloads: 5
Repository: https://github.com/teeeemoji/vue-route-sync-mixin

Install

npm install vue-route-sync-mixin
yarn add vue-route-sync-mixin

vue-route-sync-mixin

Travis (.com)
Codecov
npm
npm
npm bundle size
GitHub last commit
NPM

What is vue-route-sync-mixin

Vue-route-sync-mixin 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-mixin

Usage

Single File Component Example:

 <script>
+ import {createRouteSyncMixin} from 'vue-route-sync-mixin'

export default {
  // initial url would be http://xxx/#/?ps=1__10&pn=1__1
+ mixins: [createRouteSyncMixin({ps: 'pagination.pageSize',pn: 'pagination.pageNum'})],
  data() {
    return {
      pagination: {
        pageSize: 10,
        pageNum: 1
      }
    }
  }
}
</script>

API

createRouteSyncMixin

src/index.js:16-44

A series of mixins is automatically generated for the url synchronization function

Parameters

  • options {{}} A map of $route.query keys to vm's property path
    • options.KeyOfOptions {string} Key of options is the value key on url query string,
      and its also the key in vm.$route
    • options.ValueOfOptions {string} Value of options is a path to find the actual value in vm

Returns {} A series of mixins

processEscapeStr2Value

src/index.js:54-54

process escape string to value with its data type

Parameters

  • str {string}

Returns (string | any | undefined | number)

processValue2EscapeStr

src/index.js:64-64

process value to escape string

Parameters

  • val {any}

Returns string

TODO

  • write demo

License

This project is licensed under the MIT license.

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code