//腳本里 gameObject = 9;//第一層的 t = { gameObject =10;//第二層的 function k1(){ gameObject;//這是第一層的,這需要注意 this.gameObject;//這是自己第二層的 t.gameObject;//這是自己第二層的 } } //也就是說,表里要使用自己的,就需要用 this,不然會被當(dāng)成最外的 //this是指向當(dāng)前的表的,但有一種情況,this是失效的 xx = { //這是找不到this的,因?yàn)槭菍⒑瘮?shù)賦予變量,而這個(gè)函數(shù)上面沒有東西 x1 = function(){} //這能找到,因?yàn)閤2上面是xx表 function x2(){} }
更多建議: