Created
January 17, 2017 10:35
-
-
Save scq000/d7293ed9806fa517adeff30a8b5c31cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 将元素属性和数据进行绑定 | |
function bind(obj, prop, element, config) { | |
if(config) { | |
Object.defineProperty(obj, prop, { | |
get: config.get, | |
set: config.set, | |
enumerable: true, | |
configurable: true | |
}); | |
}else { | |
Object.defineProperty(obj, prop, { | |
get: function () { | |
return element.val(); | |
}, | |
set: function (newValue) { | |
element.val(newValue); | |
}, | |
enumerable: true, | |
configurable: true | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment