如何卸载实用程序模块(jQuery.sap.require 相反)
How to unload a utility module (opposite of jQuery.sap.require)
我在 Fiori Launchpad 中卸载 custom utility 模块时遇到问题。我想这样做是为了清理资源。
模块定义:
jQuery.sap.declare("sap.ui.demo.tdg.util.Formatter");
sap.ui.demo.tdg.util.Formatter = {
methodCall: function() {
...
模块在组件初始化中加载:
myComponentPath.Component.prototype.init = function(){
jQuery.sap.require("sap.ui.demo.tdg.util.Formatter");
sap.ui.demo.tdg.util.Formatter.methodCall(); <- error happens here when opening 2nd time
我试图在组件 destroy 上将模块设置为 null 但后来我得到 undefined 在 Fiori Launchpad 中第二次打开应用程序时 sap.ui.demo.tdg.util.Formatter:
myComponentPath.Component.prototype.destroy = function(){
sap.ui.demo.tdg.util.Formatter = null;
或者我只是偏执狂,不应该关心资源是否已正确清理。 :)
谢谢!
你可以试试:
jQuery.sap.unloadResource("some/util/Formatter.js", false, true, true);
编辑:
jQuery.sap.require 加载资源并将其保存到名为 mModules 的内部映射中。使用 unloadResource,您可以从此地图中删除一个条目。路径后面的参数描述了如何处理全局变量等依赖关系。
但是你可以自己阅读文档here。
我在 Fiori Launchpad 中卸载 custom utility 模块时遇到问题。我想这样做是为了清理资源。
模块定义:
jQuery.sap.declare("sap.ui.demo.tdg.util.Formatter");
sap.ui.demo.tdg.util.Formatter = {
methodCall: function() {
...
模块在组件初始化中加载:
myComponentPath.Component.prototype.init = function(){
jQuery.sap.require("sap.ui.demo.tdg.util.Formatter");
sap.ui.demo.tdg.util.Formatter.methodCall(); <- error happens here when opening 2nd time
我试图在组件 destroy 上将模块设置为 null 但后来我得到 undefined 在 Fiori Launchpad 中第二次打开应用程序时 sap.ui.demo.tdg.util.Formatter:
myComponentPath.Component.prototype.destroy = function(){
sap.ui.demo.tdg.util.Formatter = null;
或者我只是偏执狂,不应该关心资源是否已正确清理。 :)
谢谢!
你可以试试:
jQuery.sap.unloadResource("some/util/Formatter.js", false, true, true);
编辑: jQuery.sap.require 加载资源并将其保存到名为 mModules 的内部映射中。使用 unloadResource,您可以从此地图中删除一个条目。路径后面的参数描述了如何处理全局变量等依赖关系。
但是你可以自己阅读文档here。