假设我现在有一段代码function globalActions(){ App = function(obj) { console.log('This is a global App, app id is ' + obj.id); } Page = function(obj) { console.log('This is a global Page, page id is ' + obj.id); } App({id: 'app'}); Page({id: 'page'}); myGlobalActions();}function pluginActions(){ let originalMyPluginActions = myPluginActions; myPluginActions = function(){ App = undefined Page = function(obj) { console.log('This is a plugin Page, page id is ' + obj.id); } originalMyPluginActions.apply(this, arguments); }}function myGlobalActions(){ myPluginActions(App, Page);}function myPluginActions(){ let originalApp = arguments[0]; let originalPage = arguments[1]; arguments[0] = function() { console.log('hello I try to modify the global App fn'); return originalApp.apply(this, arguments); }; arguments[1] = function() { console.log('hello I try to modify the global Page fn'); return originalPage.apply(this, arguments); };}pluginActions();globalActions();在myGlobalActions里定义App或Page(App = / Page =)是禁止的,能够修改的只有myGlobalActions和myPluginActions,请问怎么才能修改globalActions里的App和Page?
添加回答
举报
0/150
提交
取消