How to use the @tarojs/taro-h5._$router function in @tarojs/taro-h5

To help you get started, we’ve selected a few @tarojs/taro-h5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NervJS / taro / packages / taro-router / src / history / createHistory.ts View on Github external
// 记录最后一个location,浏览器前进后退按钮用
    lastLocation = {...nextState.location}

    stateKey = Number(nextState.location.state!.key)

    serialize()

    history.length = globalHistory.length
    const params = {
      fromLocation,
      toLocation: history.location,
      action: history.action
    }

    Taro._$router = history.location
    Taro.eventCenter.trigger('__taroRouterChange', {...params})
    transitionManager.notifyListeners({...params})
  }
github NervJS / taro / packages / taro-router / src / router / router.tsx View on Github external
render () {
    const currentLocation = Taro._$router
    return (
      <div style="{{">
        {this.state.routeStack.map(({ path, componentLoader, isIndex, key, isRedirect }, k) =&gt; {
          return (
            
</div>
github NervJS / taro / packages / taro-router / src / history / __mocks__ / createHistory.ts View on Github external
const listen = (listener: History.LocationListener) => {
  if (listeners.length) return noop

  listeners.push(listener)
  return () => {
    listeners.length = 0
  }
}

const notify = (opts) => {
  listeners.forEach(v => {
    v(opts)
  })
}

Taro._$router = initLocation

const history = {
  listen,
  location: initLocation,
  notify
}

export default () => {
  return history
}