我有这些动态值(params)发送到API,所以我可以在输入中插入格式化文本(大小和颜色)后获得PNG图像:
params = {
"handwriting_id": "8X3WQ4D800B0",
"text": "",
"handwriting_size": "",
"handwriting_color": "",
}
前两个是必需的,而不是第三个和第四个 . 我的问题是最后一个参数(颜色)被忽略了,不太可能是其他参数:我得到的图像是我选择的尺寸和我写的文字,但没有颜色,总是黑色 . 这是一个令人尊敬的HTML:
<mat-form-field class="block center">
<mat-select placeholder="Choose Color" [(ngModel)]="selectedColor" [(ngModel)]="params.handwriting_color" (change)="changeColor()">
<mat-option value="#FF0000" selected="selected">Red
</mat-option>
<mat-option value="#8c30ec">Blue
</mat-option>
<mat-option value="#ec30db">Violet
</mat-option>
</mat-select>
</mat-form-field>
这是带调用的url自定义字符串和那些参数:
const url =
`https://api.handwriting.io/render/png?handwriting_id=${this.params.handwriting_id}&text=${this.params.text}&handwriting_size=${this.params.handwriting_size}&handwriting_color=${this.params.handwriting_color}`;
老实说,我没有得到它;为什么只有一个被忽略的参数?任何帮助都会被贬低
编辑:
正如@Fateh Mohamed建议我试过这个:
params = {
"handwriting_id": "8X3WQ4D800B0",
"text": "",
"handwriting_size": "",
"handwriting_color": "",
}
color = encodeURIComponent(this.params.handwriting_color);
然后将其传递给url:
const url =
`https://api.handwriting.io/render/png?handwriting_id=${this.params.handwriting_id}&text=${this.params.text}&handwriting_size=${this.params.handwriting_size}&handwriting_color=${this.color}`;
但仍然没有结果......
1 回答
请用 :
编码特殊字符