1.1.6 • Published 6 years ago

wepy-router v1.1.6

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Wepy-router npm.io

Install

npm i wepy-router --save

Config & Init

app.wepy

import Router from 'wepy-router'  
const config = {
  pages: ['pages/index'],
  subPackages: [
    {
      root: 'pages/common',
      pages: ['a', 'b']
    },
  ],
  window: {
    backgroundTextStyle: 'light',
    navigationBarBackgroundColor: '#fff',
    navigationBarTitleText: 'xxx',
    navigationBarTextStyle: 'black'
  }
}
export default class extends wepy.app {
  config = config;
  router = new Router(config);
  globalData = {};
  constructor() {
    super()
    this.use('requestfix') 
  }
  onLaunch() {
    console.log(wepy.$router)
  }
}

Useing in page or component

default navigate

wepy.$router.push('/pages/common/a', {
  id: 1
})

or

wepy.$router.push({
  path: '/pages/common/a',
  query: {
    id: 1
  }
})

use by name

wepy.$router.push({
  name: 'CommonA'
})

reLaunch

wepy.$router.push({
  path: '/pages/common/b',
  relaunch: true
})

or

wepy.$router.push(path: '/pages/common/a',{},true)

navigate back or front

Back to last page

wepy.$router.go(-1)

Going front

wepy.$router.go(1)

You won't be caring about if it should be switching tabbar
More than pages length have disposed

More

if you want to use this insdead of wepy.$router

import { routerMinx } from 'wepy-router'  
export default class Index extends wepy.page {
  mixins = [routerMinx]
  onLoad() {
    conosle.log(this.$router)
  }
}

or

import {withRouter} from 'wepy-router'  
@withRouter  
export default class Index extends wepy.page {
  onLoad() {
    conosle.log(this.$router)
  }
}

License

ISC

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago