1.3.0 • Published 9 years ago

crystal-state v1.3.0

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

crystal-state

使用location或者hash存储状态的组件

new

var State = require('crystal-state');

// 基于history
var state = new State.Location();
// 或者基于hash
var state = new State.Hash();

onChange(fn) 监听状态变化事件

state.onChange(function(data) {
    console.log(data);
});

start() 启动

state.start();

getData() 获取当前的data

setData(data) 设置当前的data

    state.setData({
        path: '/a/b',
        query: {
            a: 1
        }
    })

data

  • data.path String 当前的路径
  • data.query Object 当前的参数

/a/b?c=1&d=2 转化成的data对象是

{
    "path": "/a/b",
    "query": {
        "c": 1,
        "d": 2
    }
}
1.3.0

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago