假设我有一个角度分量,即<this-thing></this-thing>它的作用。
现在我想添加一些额外的东西,即如果有发光<this-thing glows></this-thing>属性
,我希望组件稍微改变一下。
<this-thing [glows]="true"></this-thing>我已经设法通过我拥有的组件来做到这一点
@Input() public set glows(value: boolean) {
console.log(value);
}
Run Code Online (Sandbox Code Playgroud)
但这变得太冗长了。
如果组件上没有“glows”属性,则该属性为 false,如果有,则为“true”。
有没有更好的方法来实现这一目标?
感谢您的关注。
有人可以帮我解决有关 Laravel 中 Guzzle 的问题吗?
我有一段使用curl 的代码,它可以工作。
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, ['userId' => $appUserId]);
curl_setopt($ch, CURLOPT_URL, $url);
$content = curl_exec($ch);
var_dump($content); // I get a response, response is good.
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)
我得到了一个很好的旧回复,其中包含我需要的所有数据。简单又美好。
然而,我工作的公司在整个应用程序中都使用 Guzzle,所以当我这样使用 Guzzle 时。
$client = new GuzzleHttp\Client();
try {
$res = $client->request('POST', $url, [
'form_params' => [
'userId' => $appUserId
],
'headers' => ['Content-Type' => 'application/json', 'Accept' => 'application/json'],
// I have tried every imaginable header.
]);
$result = json_decode($res->getBody());
echo $res->getBody();
var_dump($result);
} catch (\GuzzleHttp\Exception\RequestException $e) …Run Code Online (Sandbox Code Playgroud)