【发布时间】:2019-10-19 00:20:40
【问题描述】:
我正在使用 angular 7 和 joint.js 来创建我自己的形状定义。 例如,
joint.shapes.devs.Model.define("devs.Type",
{
size: {
width: 300,
height: "auto"
}
});
joint.shapes.standard.Rectangle.define('examples.CustomRectangle', {
attrs: {
body: {
rx: 10, // add a corner radius
ry: 10,
strokeWidth: 1,
fill: 'cornflowerblue'
},
label: {
textAnchor: 'left', // align text to left
refX: 10, // offset text from right edge of model bbox
fill: 'white',
fontSize: 18
}
}
});
var rect2 = new joint.shapes.examples.CustomRectangle();
var a1 = new joint.shapes.devs.Type(node);
编译代码给了我两个错误
错误 TS2339:“typeof devs”类型上不存在属性“Type” 错误 TS2341:类型“typeof”上不存在属性“示例” 形状”。
我该如何解决这个问题?
另外,客户Link定义了transitionColor方法,但是在paper.on("link:mouseover",....中不能调用,报错
“链接”类型上不存在属性“transitionColor”。
joint.dia.Link.define(
"devs.Link",
{
attrs: {
line: {
connection: true
},
wrapper: {
connection: true,
strokeWidth: 2,
strokeLinejoin: "round"
}
}
},
{
markup: [
{
tagName: "path",
selector: "wrapper",
attributes: {
fill: "none",
cursor: "pointer",
stroke: "transparent"
}
},
{
tagName: "path",
selector: "line",
attributes: {
fill: "none",
"pointer-events": "none"
}
}
],
transitionAsync: function (...args) {
return new Promise(resolve => {
this.transition(...args);
this.on("transition:end", () => {
resolve();
});
});
},
transitionColor: function (color, { delay = 0, duration = 100 }) {
return this.prop("attrs/line/stroke", color);
},
transitionOpacity: function (opacity, { delay = 0, duration = 100 }) {
return this.prop("attrs/line/opacity", opacity);
}
}
);
paper.on("link:mouseover", (linkView: any) => {
const links = this.graph.getLinks();
links.map(link => {
if (link === linkView.model) {
return;
}
link.transitionColor(theme.colors.line.inactive, {duration:500});
link.toBack()
});
});
【问题讨论】:
标签: angular typescript jointjs