1. Bindable.js雙向數(shù)據(jù)綁定JS庫

        聯(lián)合創(chuàng)作 · 2023-09-22 10:48

        Bindable.js 實現(xiàn)了靈活、快速的雙向數(shù)據(jù)綁定的 JavaScript 庫。

        Two-way data binding means linking properties of two separate objects - when one changes, the other will automatically update with that change.  It enables much easier interactions between data models and UIs, among other uses outside of MVC.

        Bindable.js is similar to Ember's data-binding system, except it doesn't include anything View related, so the library has many use-cases - whether replacing Backbone's Model, providing a way to maintain the state between server <-> client for a realtime front-end application (similar to Firebase), or perhaps a way to communicate between server <-> server for a realtime distributed Node.js application.

        Projects using bindable.js

        • Paperclip.js - data-bindable templating engine.

        • Sherpa.js - online tours library

        • Mojo.js - javascript MVC framework.

        • AWSM - aws library.

        • ditto - synchronized user interactions across browsers.

        示例代碼:

        var bindable = require("bindable");
        
        var person = new bindable.Object({
          name: "craig",
          last: "condon",
          location: {
            city: "San Francisco"
          }
        });
        
        person.bind("location.zip", function(value) {
          // 94102
        }).now();
        
        //triggers the binding
        person.set("location.zip", "94102"); 
        
        //bind location.zip to another property in the model, and do it only once
        person.bind("location.zip", { to: "zip", max: 1 }).now();
        
        //bind location.zip to another object, and make it bi-directional.
        person.bind("location.zip", { target: anotherModel, to: "location.zip", bothWays: true }).now();
        
        //chain to multiple items, and limit it!
        person.bind("location.zip", { to: ["property", "anotherProperty"], max: 1 }).now();
        
        
        //you can also transform data as it's being bound
        person.bind("name", {
          to: "name2",
          map: function (name) {
            return name.toUpperCase();
          }
        }).now();
        瀏覽 10
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
          
          

            1. 少妇特黄v一区二区三区图片 | 成年人床上视频 | 国产精品一区二区不卡 | 俺来也俺去也www色 | 国产精品久久久久久久久久免费看 |