How can I implement MVVM with offline storage and Knockout.js?

后端 未结 4 1000
旧巷少年郎
旧巷少年郎 2021-02-09 04:22

I can implement Mvvm with Knockout.js. But I want to use it with cross browser(FF and Chrome) supported Html 5 offline storage.

I want to bind html objects to offline

4条回答
  •  孤独总比滥情好
    2021-02-09 05:16

    I haven't tried it, but there is a knockout.localStorage project on GitHub, that seems to be what you are looking for.

    With that plugin, you should be able to pass an object as a second argument, when you create your observable, which saves the observable into localStorage.

    From the documentation:

    var viewModel = {
      name: ko.observable('James', {persist: 'name'})
    }
    
    ko.applyBindings(viewModel);
    

提交回复
热议问题