Skip to content

Promise the router request, then do anything you want .

Notifications You must be signed in to change notification settings

wanyaxing/vue-router-then

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-router-then

demo | 中文

this.$routerThen.push().then()

Promise the router request, then do anything you want .

example.vue

methods:{
    clickSomeOne:function(){
        this.$routerThen.push('/hello_world').then(vm=>{
            console.log(vm);
        });
    },
}

v-model-link

v-model-link: add a eventListener of the element or component, to catch the input event in next router page.

App.vue
<template>
    <keep-alive>
        <router-view class="transit-view"></router-view>
    </keep-alive>
</template>

example.vue
<template>
    <div>
        <input v-model-link="'/select_someone'" @input="inputOfModelLink"/>

        <inputCustomer v-model="fee" v-model-link="'/select_fee'" />

        <textarea v-model="price" v-model-link="'/select_price'" ></textarea>
    </div>
</template>
<script>
methods:{
    jumpToNextPage:function(value){
        this.$routerThen.modelLink('/select_price',value=>{
            this.inputOfModelLink(value);
        });
    },
}
</script>


select_someone.vue
<script>
methods:{
    clickSomeOne:function(value){
        this.$emit('input',value);
        this.$router.go(-1);
    },
}
</script>

INSTALL

npm install vue-router-then --save;
import Vue from 'vue'
import router from './router'

import routerThen from 'vue-router-then';
routerThen.initRouter(router)
Vue.use(routerThen)

DEVELOP

  • Code on src/index.js
  • Gulp it
  • pull it to me on github.
    npm install
    gulp
  • You need install gulp in your computer if you hasnot have it.
    sudo npm install -g gulp
  • publish the code to npm if you want to do it.
    npm config set registry=http://registry.npmjs.org

    npm publish

License

MIT