0.0.2 • Published 2 years ago

navigation-polyfill v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

English | 简体中文

navigation-polyfill implements part of the functionality of Navigation API based on Hisotry API emulation.

  • navigation.entries()
  • navigation.currentEntry

    • navigation.currentEntry.id
    • navigation.currentEntry.key
    • navigation.currentEntry.index
    • navigation.currentEntry.url
    • navigation.currentEntry.getState
  • navigation.canGoBack

  • navigation.canGoForward
  • navigation.navigate
  • navigation.reload
  • navigation.traverseTo
  • navigation.back
  • navigation.forward
  • navigation.onnavigate
  • navigation.onnavigatesuccess
  • navigation.onnavigateerror
  • navigation.oncurrententrychange
  • navigation.addEventListener()
  • navigation.removeEventListener()

Installation

npm install navigation-polyfill

Using

navigation-polyfill must be injected in the first line of code of the program.

// main.js
import 'navigation-polyfill';
// import 'others';
// ...

// case.js
import navigation from 'navigation-polyfill'
navigation.addEventListener("navigate", function (event) {
  event.preventDefault(); // blocking the opening new route
  console.log(event.navigationType); // 'reload' | 'push' | 'replace' | 'traverse'
  console.log(event.destination.id);
  console.log(event.destination.index);
  console.log(event.destination.url);
  console.log(navigation.entries());
});
0.0.2

2 years ago

0.0.1

2 years ago