Obsolete Members for Qt
以下 QML 类型Qt的成员已被弃用。提供它们是为了让旧源代码继续工作。我们强烈建议不要在新代码中使用它们。
方法
- object include(string url, jsobject callback)
(deprecated)
方法文件
|
该方法已被弃用。我们强烈建议不要在新代码中使用该方法。
不应使用此方法。请使用 ECMAScript 模块以及本地 JavaScriptimport
和export
语句。
包含另一个 JavaScript 文件。此方法只能在 JavaScript 文件中使用,不能在普通 QML 文件中使用。
这会将url 中的所有函数导入当前脚本的命名空间。
Qt.include() 返回一个描述操作状态的对象。该对象只有一个属性status
,可设置为以下值之一:
符号 | 值 | 说明 |
---|---|---|
result.OK | 0 | 包含成功完成。 |
result.LOADING | 1 | 正在从网络加载数据。 |
result.NETWORK_ERROR | 2 | 获取 url 时发生网络错误。 |
result.EXCEPTION | 3 | 执行包含的代码时出现 JavaScript 异常。在这种情况下,将设置额外的exception 属性。 |
status
属性将随着操作的进行而更新。
如果提供了回调,则会在操作完成时调用callback 。回调传递的对象与 Qt.include() 调用返回的对象相同。
警告: 在严格模式下使用此函数不会将标识符放入当前上下文。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.