Skip to content

Instantly share code, notes, and snippets.

@scq000
Created January 17, 2017 10:35
Show Gist options
  • Save scq000/d7293ed9806fa517adeff30a8b5c31cd to your computer and use it in GitHub Desktop.
Save scq000/d7293ed9806fa517adeff30a8b5c31cd to your computer and use it in GitHub Desktop.
// 将元素属性和数据进行绑定
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