我遇到了更复杂的键值对的问题...如果我想将值设置为对象怎么办?
我遇到了这个问题:
const includeStr = JSON.stringify({include: 'match-timeline-events'});
const params: HttpParams = new HttpParams().set('filter', includeStr);
当我在以下地方使用它时:
this.http.get(environment.apiPath + '/clientMatches/' + id, {params})
我进入标题然后设置此
(urlencoded): filter:%7B%22include%22:%22match-timeline-events%22%7D
但出于某种原因,:不进行编码,字符串应该
(urlencoded): filter:%7B%22include%22%3A%22match-timeline-events%22%7D
任何想法如何解决这个问题?
答案 0 :(得分:1)
这可能是应该报告的错误。无论如何,您可以使用可以扩展默认值custom encoder的$this->recolor($this->color, $baseHex);
$this->recolor($this->eyes, $eyesHex);
$this->recolor($this->eyebrows, $eyebrowsHex);
$this->recolor($this->pads, $padsHex);
$this->recolor($this->nose, $noseHex);
$this->recolor($this->claws, $clawsHex);
$this->recolor($this->tongue, $tongueHex);
$this->image->newImage(800, 598, new \ImagickPixel('transparent'));
$this->image->compositeImage($this->color, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->compositeMarkings();
$this->image->compositeImage($this->eyes, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->image->compositeImage($this->eyebrows, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->image->compositeImage($this->pads, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->image->compositeImage($this->nose, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->image->compositeImage($this->claws, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->image->compositeImage($this->tongue, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->mask($this->image, $this->color);
$this->bg->compositeImage($this->image, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->bg->compositeImage($this->lines, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->bg->compositeImage($this->logo, Imagick::COMPOSITE_DEFAULT, 0, 0);
$this->bg->setImageColorSpace(Imagick::COLORSPACE_SRGB);`
HttpUrlEncodingCodec
来解决此问题。
可以看出,HttpParams
使用custom function的doesn't encode a colon on purpose。