var obj = {
f1: function() {
var p = new this.f2()
Object.assign(this, p)
console.log(1, this)
},
f2: function() {
console.log(2, this)
this.f3 = function() {
console.log(3, this)
}
}
}
(above is the sample code, and the actual code is Mini Program"s)
now I get this
in f2
is a {imageLoaded: examples ()}
, why not this
pointing to obj
, what can I do to add f3
to obj
, and also in f2
Page({
f1: function() {
console.log(this) //{}
this.imageLoaded = function() {}
},
f2: function() {
const p = new this.f1()
Object.assign(this, p)
},
})
<image src="{{item}}" hidden bindload="imageLoaded"></image>