我正在将PHPStorm 8.0.3用于我当前的项目,但不幸的是它不支持JSX.在我的React组件(然后由Browserify编译)中,HTML以红色加下划线并且无效:

这只是一个小组件,但对于较大的组件肯定会变得非常烦人.代码格式也无法按预期工作.
我正在使用 aBroadcastChannel将数据从一个浏览器窗口传递到另一个浏览器窗口。但是,使用 Flow 时出现以下错误:Flow:mixed [1] 中缺少属性 `type`。
这是我的代码:
const channel = new BroadcastChannel('background');
channel.onmessage = ({ data }) => {
if (data.type === 'OK') {
this.setState({ isLoading: false, success: true, error: false });
}
else if (data.type === 'ERROR') {
this.setState({ isLoading: false, success: false, error: true });
}
};
Run Code Online (Sandbox Code Playgroud)
我也尝试定义我自己的类型:
type MessageType = {
type: String,
payload: String,
};
...
channel.onmessage = ({ data }: { data: MessageType }) => {
if (data.type === 'OK') { …Run Code Online (Sandbox Code Playgroud) 我想知道如何在我的Raspberry Pi上安装PHP 5.6.x. 目前已安装版本5.4.41,并且由于新规范我想升级到5.6.10.我已经看过这个教程但是控制台的输出告诉我出了问题.
pi@raspberry:~$ sudo apt-get update
Hit http://packages.dotdeb.org wheezy-php56 Release.gpg
Hit http://archive.raspberrypi.org wheezy Release.gpg
Get:1 http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]
Hit http://raspberrypi.collabora.com wheezy Release.gpg
Hit http://packages.dotdeb.org wheezy-php56 Release
Get:2 http://mirrordirector.raspbian.org wheezy Release [14,4 kB]
Hit http://raspberrypi.collabora.com wheezy Release
Hit http://archive.raspberrypi.org wheezy Release
Hit http://packages.dotdeb.org wheezy-php56/all Sources
Hit http://raspberrypi.collabora.com wheezy/rpi armhf Packages
Hit http://archive.raspberrypi.org wheezy/main armhf Packages
Get:3 http://mirrordirector.raspbian.org wheezy/main armhf Packages [6.904 kB]
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en_US
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en
Ign http://archive.raspberrypi.org wheezy/main Translation-en_US
Ign …Run Code Online (Sandbox Code Playgroud) 我有一个TrimInput中间件注册为我的路由的中间件,以在请求到达控制器之前修剪所有用户输入.在中间件中,修剪似乎有效,但是当我在操作中转储请求时,请求似乎没有修改,就像之前没有中间件一样.
这有什么问题? 问题是ClientRequest,但为什么呢?
// TrimInput.php
<?php namespace App\Http\Middleware;
use Closure;
class TrimInput {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next) {
$request->replace($this->trimArrayRecursive($request->all()));
// When I dump $request right here, all seems fine (the input is trimmed)
return $next($request);
}
protected function trimArrayRecursive($input) {
if (!is_array($input)) {
return trim($input);
}
return array_map([$this, 'trimArrayRecursive'], $input);
}
}
// Somwhere in my routes.php
Route::post('/test', ['middleware' …Run Code Online (Sandbox Code Playgroud) 考虑到以下 GraphQL 突变:
type Mutation {
updateUser(id: ID!, newEmail: String!): User
updatePost(id: ID!, newTitle: String!): Post
}
Run Code Online (Sandbox Code Playgroud)
Apollo 文档指出,完全有可能在一个请求中执行多个突变,例如
mutation($userId: ID!, $newEmail: String!, $postId: ID!, $newTitle: String!) {
updateUser(id: $userId, newEmail: $newEmail) {
id
email
}
updatePost(id: $postId, newTitle: $newTitle) {
id
title
}
}
Run Code Online (Sandbox Code Playgroud)
1.真的有人这么做吗?如果你不明确地这样做,批处理会导致这种突变合并吗?
2. 如果您在突变中执行多个操作,您将如何正确处理错误?
我见过很多人建议在服务器上抛出错误,以便服务器响应如下内容:
{
errors: [
{
statusCode: 422,
error: 'Unprocessable Entity'
path: [
'updateUser'
],
message: {
message: 'Validation failed',
fields: {
newEmail: 'The new email is not a valid email address.' …Run Code Online (Sandbox Code Playgroud) 我有两个实体,aUser和一个Post实体。一个用户可以有多个帖子。
我想根据帖子标题和作者姓名查找帖子,如下所示:
const post = await postsRepository.find({
where: {
title: postTitle,
user: {
name: userName,
},
},
relations: ['user'],
});
Run Code Online (Sandbox Code Playgroud)
Typeorm生成以下 SQL:
SELECT `Post`.`id` AS `Post_id`, `Post`.`title` AS `Post_title`, `Post`.`user_id`
AS `Post_user_id`, `Post__user`.`id` AS `Post__user_id`, `Post__user`.`name` AS
`Post__user_name` FROM `posts` `Post` LEFT JOIN `users` `Post__user` ON
`Post__user`.`id`=`Post`.`user_id` WHERE (`Post`.`user_id` = ?) -- PARAMETERS: [null]
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,它根本没有查询 name 属性。
但它不起作用,我在文档中找不到任何内容。
[编辑]:另一方面,以下代码按预期工作,但未使用联接来查询关系:
const user = await usersRepository.findOne({ name: userName });
const post = await postsRepository.find({
where: {
title: …Run Code Online (Sandbox Code Playgroud)