var n=999;
function f1(){
alert(n);
}
f1();//999
function f1(){
var n=999;
}
alert(n);//error
function f1(){
n=999;
}
f1();
alert(n);//999
function f1(){
var n=999;
function f2(){
alert(n);//999
? ? ? ? ? ? }
}
function f1(){
var n=999;
function f2(){
alert(n);
}
return f2;//f2就是閉包,閉包就是能夠讀取其他函數(shù)內(nèi)部變量的函數(shù)。f2作為返回值,
}
var result=f1();就可以在f1外部讀取它的內(nèi)部變量了
result();//999
前面提到的可以讀取函數(shù)內(nèi)部的變量,另一個就是讓這些變量的值始終保持在內(nèi)存中
刪除
? ? ? ? // axios({
? ? ? ? //? url: process.env.BASE_API + "/user/deleteFindFunnelDetail",
? ? ? ? //? method: "post",
? ? ? ? //? params: { reportId: rows.reportId },
? ? ? ? //? transformResponse: [
? ? ? ? //? ? function(response) {
? ? ? ? //? ? ? _this.query();
? ? ? ? //? ? }
? ? ? ? //? ],
? ? ? ? //? headers: { "Content-type": "application/x-www-form-urlencoded" }
? ? ? ? // });
? ? ? ? //? axios.post(process.env.BASE_API+'/user/deleteFindFunnelDetail',{reportId: rows.reportId}).then(function(response){
? ? ? ? //? ? ? ? this.query()
? ? ? ? //? ? })
查詢
? ? //? axios({
? ? //? ? url: process.env.BASE_API + "/search",
? ? //? ? method: "post",
? ? //? ? params: _this.searchfrom,
? ? //? ? transformResponse: [
? ? //? ? ? function(response) {
? ? //? ? ? ? // console.log(JSON.parse(response).data.data)
? ? //? ? ? ? _this.tableData = JSON.parse(response).data.data;
? ? //? ? ? ? _this.total = JSON.parse(response).data.pager.totalCount;
? ? //? ? ? }
? ? //? ? ],
? ? //? ? headers: { "Content-type": "application/x-www-form-urlencoded" }
? ? //? });