data (){
succesCallBack,
},
clickTarget () {
this.successCallBack && this.successCallBack('成功获取数据并回调');
}
methods:{
this.successCallBack() = function(res) {
console.log(res)
},
}
点击clickTarget事件,触发successCallBack回调函数,打印'成功获取数据并回调'
data (){
succesCallBack,
},
clickTarget () {
this.successCallBack && this.successCallBack('成功获取数据并回调');
}
methods:{
this.successCallBack() = function(res) {
console.log(res)
},
}
点击clickTarget事件,触发successCallBack回调函数,打印'成功获取数据并回调'
本文标题:JS 闭包的简单实用
本文链接:https://www.haomeiwen.com/subject/ytkxfdtx.html
网友评论