【发布时间】:2021-06-05 16:33:48
【问题描述】:
我在fabricjs中遇到一个问题,问题是
- 我的当前代码具有默认背景,我可以更改背景颜色
- 如果我放置任何对象或文本,如果我想将该对象的背景颜色更改为透明度
- 我正在尝试更改形状颜色,但背景颜色正在改变。
- 实际上我在下面的 html 中发现了问题,我有 props.canvasFill 我认为应该有两个参数,因为如果你看到我的 ts 代码
这是我的 HTML
**<input type="text" class="form-control" [cpPosition]="'right'" [cpPresetColors]="customColors" [cpOKButton]="true" [cpAddColorButtonText]="'Speichern'" [cpAddColorButton]="true" [cpOKButtonClass]="'btn btn-light btn-sm'" [cpSaveClickOutside]="false" [(colorPicker)]="props.canvasFill"
[style.background]="props.canvasFill" [value]="props.canvasFill" (cpPresetColorsChange)="updateColorPresets($event)"
(colorPickerChange)="setFillColor($event)"/>**
这是我在 html 中的 ts 代码,目前它有 canvasFile 我必须使用 fill 和 canvasfill 我不知道如何使用它
props: any = {
canvasFill: '#ffffff',
canvasImage: '',
id: null,
opacity: null,
fill: null,
stroke: null,
strokeWidth: null,
fontSize: null,
lineHeight: null,
charSpacing: null,
fontWeight: null,
fontStyle: null,
textAlign: null,
fontFamily: 'Open Sans',
TextDecoration: '',
scale: 1,
angle: 0
};
setFillColor(swatch: any): void {
this.palettes.selected = swatch;
this.props.fill = swatch.key;
console.log(this.props.fill, '& ' ,swatch.key);
this.setFill();
if (!this.props.canvasImage) {
console.log('say hi')
this.canvas.backgroundColor = this.props.canvasFill;
this.canvas.renderAll();
};
}
console.log(this.props.fill, '& ' ,swatch.key); i am getting Undefined & undefined
【问题讨论】:
-
你得到的
swatch变量的值是多少? -
我越来越不确定和未定义
-
不是 swatch.key.. 只是 swatch 变量。在您的方法中将第一行写为
console.log(swatch)。控制台中打印的内容 -
@NareshJ 获取颜色代码 setFillColor(swatch: any): void { console.log(swatch);
-
#d82727 这样的颜色代码
标签: angular angular8 fabricjs angular11