Sloth-state.js

Because the project is written using other front-end frameworks, there are not many pages, only need a page with parameters jump, so write this method; Does not depend on any JS;

1/ Sloth.state.setConfig

Set the name of each page to pass value and jump

Sloth.state.setConfig({ //'default'Is the name of the route used for the go method to jump to template is the page path; Param is the absolute path to host. with'/'separate'default': {
   template: 'index.html',
   path: '/',
   param: ' '
 },
 'index': {
   template: 'index.html',
   path: '/',
   param: ' '
 },
 'foods': {
   template: 'foods.html',
   path: '/',
   param: '/id'
 })
Copy the code

2/Sloth.state.go

The first argument to the go method is the route name; The second is the transmission;

Sloth.state.go('index',{id:1});

3/Sloth.state.goBack

Sloth.state.goback ();

4/Sloth.state.currentPage

Is the name of the route to the current page;

5/Sloth.state.params

Gets the sloth.state. params parameter received for the hash value of this page

6/Sloth.state.chang

Parameter to call when the hash value changes

 Sloth.state.chang(function() {/ / pagehashTrigger event when value changes});Copy the code

7/Sloth.state.backViewUrl

Return the url of the previous page sloth.state.backviewURL ();

These are some of the methods that have been implemented and are sufficient for now;

Git: github.com/xueliangGit…