js对象内部访问this修饰的成员函数示例
时间:2024-04-18 10:47:04
用wrapper封装这样在对象内外都可以访问
function MapPool(){
function createMarker(name, lat, lng, state){
var marker = new AMap.Marker({
position : new AMap.LngLat(lng, lat),
});
//the function mapMoveTo is not accessible here too
AMap.event.addListener(marker, "click",function(e){
//moveMapTo(key, name, state)
//or this.moveMapTo(key, name, state) will raise a unresolved function error
//you should write wrapper function as a member variable
_mapMoveTo(key, name, state);
});
}
var _mapMoveTo = function(key, name, state){
//TODO
}
this.mapMoveTo = function(key, name, state) {
_mapMoveTo(key, name, state);
}
}
标签:js,this,成员函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
【启发】不用循环计算1到100的和
2009-03-04 12:16:00
MySQL大量脏数据如何只保留最新的一条(最新推荐)
2024-01-25 22:41:04
![](https://img.aspxhome.com/file/2023/8/88498_0s.jpg)
栅格:一以贯之
2008-07-22 12:19:00
![](https://img.aspxhome.com/file/UploadPic/20087/22/2008722122154966s.gif)
Python中如何替换字典中的值
2022-10-04 21:21:35
使用python脚本自动生成K8S-YAML的方法示例
2023-09-19 06:12:17
Python中的exec、eval使用实例
2022-07-05 21:01:41
通过python实现弹窗广告拦截过程详解
2022-04-12 09:21:31
![](https://img.aspxhome.com/file/2023/8/71448_0s.png)
python批量导出导入MySQL用户的方法
2024-01-29 02:58:42
Go 互斥锁和读写互斥锁的实现
2024-04-25 15:00:41
关于python常见异常以及处理方法
2021-03-17 06:13:34
tensorflow 中对数组元素的操作方法
2022-01-22 11:35:37
![](https://img.aspxhome.com/file/2023/5/70785_0s.jpg)
ASP+SQL Server构建网页防火墙
2009-01-21 19:56:00
python中使用.py配置文件的方法详解
2022-02-13 19:57:22
微信小程序-滚动消息通知的实例代码
2024-04-16 10:41:16
![](https://img.aspxhome.com/file/2023/8/136558_0s.gif)
matplotlib.pyplot绘图显示控制方法
2023-07-03 15:44:20
![](https://img.aspxhome.com/file/2023/3/62903_0s.jpg)
Web设计中的黄金分割[译]
2009-02-20 13:41:00
![](https://img.aspxhome.com/file/UploadPic/20092/20/01-25s.jpg)
go-micro微服务domain层开发示例详解
2024-04-26 17:25:04
为导入文件加上时间戳标记的两种方法
2009-01-07 14:14:00
js表格拖选动态效果COOL而实用
2007-08-05 12:07:00
![](https://img.aspxhome.com/file/UploadPic/up/2007080512171065.gif)
Python matplotlib底层原理解析
2021-05-11 07:05:29
![](https://img.aspxhome.com/file/2023/1/93631_0s.png)