Mashup Builder > 迁移旧式混搭 > 替换混搭中的非安全表达式 > 受支持的运行时函数和对象
受支持的运行时函数和对象
替换混搭中的非安全函数时,必须审阅并更新函数表达式。为避免新的标准函数出现混搭运行时问题和意外行为,必须移除对下表中所列对象和函数的所有参考。
已弃用对象和函数
对象或函数名称
示例
location
location.reload();
location.hostName !== ‘localhost’;
* 
此对象被 TW.location 所替换。
widget
widget.getProperty('DisplayName') === ‘ptcs-grid2’;
widget.mashup.rootWidget.getProperty('remoteAccessibleThing') == null; widget.mashup.rootWidget.getWidgets()[1].getProperty('SelectedText') == null;
history
history.back();
TW.Runtime.<any object>.(<any function>)
Output = TW.Runtime.Widgets.PTC_SCA_SCO_CustomFunctions.isSecure();
TW.Runtime.showHideDataFilterWidgets($(\body"), false);
Output = TW.Runtime.Widgets.PTC_SCA_SCO_CustomFunctions.getURLParameter(“mashup",url);
TW.Runtime.Widgets.AssetMonitor.refreshNeeded(isSelected,selectedTreeNode,selectedContext);
TW.Runtime.AssetMonitor.assetPropertyTitles(widget);
TW.Runtime.AssetMonitor.assetPropertyTitles(widget);
jqElement
widget.jqElement.triggerHandler('Changed');
screen
* 
在 ThingWorx 9.3.8 和 9.2.13 或更高版本中,此对象将被替换为 TW.screen
screen.width
screen.height
screen.availHeight
screen.availWidth
self
const displayName = self['DisplayName'];
sessionStorage
sessionStorage.setItem('key', ‘value’);
* 
仅非安全函数支持已弃用的函数和对象。
受支持的对象和函数
下表列出了验证器和表达式函数最新标准版本中支持的对象和函数:
类别
对象和函数
示例
位置
TW.location.hash
TW.location.host
TW.location.hostname
TW.location.href
TW.location.origin
TW.location.pathname
TW.location.port
TW.location.protocol
TW.location.search
TW.location.reload()
TW.location.reload();
TW.location.hostName !== ‘localhost’;
本地化
TW.Runtime.convertLocalizableString('[[token name]]')
Output = TW.Runtime.convertLocalizableString(“[[userName”]]);
日志记录
TW.log.info()
TW.log.debug()
TW.log.warning()
TW.log.error()
TW.log.debug('Logging to mashup console');
运行时根混搭
TW.Runtime.pageMashupName
TW.Runtime.actualMasterName
TW.Runtime.RootMashup.ConfigurationTables
TW.Runtime.RootMashup.CustomMashupCss
TW.Runtime.RootMashup.Data
TW.Runtime.RootMashup.DataBindings
TW.Runtime.RootMashup.Events
TW.Runtime.RootMashup.UI
TW.Runtime.RootMashup.mashupName
Output = TW.Runtime.RootMashup.mashupName;
Output = TW.Runtime.Workspace.Mashups.Current.UI.Widgets[0].Properties.Id;
Output = TW.Runtime.Workspace.Mashups.Current.Events[0].EventHandlerService;
Output = TW.Runtime.Workspace.Mashups.Current.Data.Session.UserExtension.Services[0].APIMethod;
Output = TW.Runtime.RootMashup.UI.Widgets[1].properties.SelectedText;
运行时工作区
TW.Runtime.Workspace.Mashups.CurrentMashupName
TW.Runtime.Workspace.Mashups.CurrentParameters
TW.Runtime.Workspace.Mashups.Current.ConfigurationTables
TW.Runtime.Workspace.Mashups.Current.CustomMashupCss
TW.Runtime.Workspace.Mashups.Current.Data
TW.Runtime.Workspace.Mashups.Current.DataBindings
TW.Runtime.Workspace.Mashups.Current.Events
TW.Runtime.Workspace.Mashups.Current.UI
TW.Runtime.Workspace.Mashups.Current.mashupName
Output = TW.Runtime.Workspace.Mashups.CurrentMashupName;
运行时屏幕高度和宽度
TW.screen.width
TW.screen.height
TW.screen.availHeight
TW.screen.availWidth
Output = TW.screen.width
HTTP 请求
XMLHttpRequest
let xhr = new XMLHttpRequest(); xhr.open('GET', 'http://localhost:9000/Thingworx/Users/Administrator/Properties', true); xhr.onload = function () { console.log('the value is '+ xhr.responseText); }; xhr.send();
这对您有帮助吗?