javascript - How to access the properties of the outer object in js
世界只因有你
世界只因有你 2017-05-19 10:38:10
0
2
395
        {
          pName: 'MapType',
          defaultType: 0,
          events: {
            init(o) {
              console.log(this.pName)
            }
          }
        }

As shown above, how can I get this.pName correctly

世界只因有你
世界只因有你

reply all(2)
Ty80
var obj = {
    pName: 'MapType',
    defaultType: 0,
    events: {
        init(o) {
            console.log(this.pName)
        }
    }
};

obj.events.init.call(obj);
曾经蜡笔没有小新
var obj = {
    pName: 'MapType',
    defaultType: 0,
    events: {
        init(o) {
            console.log(obj.pName)
        }
    }
}
obj.events.init();
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!