在 JointJS 中,我得到错误属性 html 在类型“类型形状”上不存在

In JointJS I get the error property html does not exist on type 'typeof shapes'

本文关键字:类型 类型形状 不存在 属性 JointJS 错误 html      更新时间:2023-09-26

我想用JointJS开发一个应用程序。我正在遵循在 JointJS 官方网站 (http://www.jointjs.com/tutorial/html-elements) 上找到的教程。到目前为止,我只写了一行:

joint.shapes.html = {};

我已经收到错误:

"属性 HTML 在类型'类型形状'上不存在"

什么?

我想

我已经找到了答案。因为实际上我没有使用javascript,而是使用打字稿。在 Typescript 中,您无法动态地向对象添加属性,因此如果形状不包含名为 html 的属性,则无法动态将其添加到其中。