如何让JS实现类似PHP的 __set __get方法?
html
javascript
prototype
如何让JS实现类似PHP的 __set __get方法?
html
javascript
prototype
估计你是想要这个:
username.__defineGetter__('_tipsTxt', function(){return this.getAttribute('_tipsTxt');});
username.__defineSetter__('_tipsTxt', function(txt){this.setAttribute('_tipsTxt', txt);});
JS属性自带set
,get
功能啊..=_= 请看DEMO:http://jsfiddle.net/7jfmafkd/
具体请查阅:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
已抢66892个
抢已抢39383个
抢已抢21815个
抢已抢2769个
抢已抢3056个
抢已抢19362个
抢