js 面向对象函数
//也可以这么写 function Objoriented(name, wx) { //构造函数加属性 this.wx = wx; this.name = name } Objoriented.prototype = { //原型加方法 showName:function(s) { return 'name =' + this.name + s }, showQQ:function() { alert('wx=' + this.wx) } } var data1 = new Objoriented('zhang', '125896347'); var data2 = new Objoriented('wu', '125896347 '); console.log(data1.showName('4444')) //还可以继续使用
//构造函数 function Objoriented(name, wx) { //构造函数加属性 this.wx = wx; this.name = name } Objoriented.prototype.showName = function() { //原型加方法 return 'name =' + this.name } Objoriented.prototype.showQQ = function() { alert('wx=' + this.wx) } var data1 = new Objoriented('zhang', '125896347'); var data2 = new Objoriented('wu', '125896347 '); //data1.showName() //还可以继续使用
//es6 写法 //构造函数 class ControlOperation{ //构造函数 constructor(formdata){//进来直接调用 this.form = formdata; } getFieldValue(s) { return this.form } setFieldValue() { } }