我正在使用这样的解构:
const { item } = content
console.log(item)
Run Code Online (Sandbox Code Playgroud)
但是我应该如何处理content === undefined- 这将引发错误?
"旧"方式如下所示:
const item = content && content.item
Run Code Online (Sandbox Code Playgroud)
所以,如果content未定义 - > item也将是未定义的.
我可以使用解构来做类似的事吗?
作为 devDependency 我已经安装了"@typescript-eslint/parser": "~4.31.2"
运行告诉我,如果我正确理解错误,则npm install需要一个包4.20.0和另一个包。4.28.3
如何处理这些 npm 包冲突?
npm ERR! While resolving: @nrwl/eslint-plugin-nx@12.9.0
npm ERR! Found: @typescript-eslint/parser@4.31.2
npm ERR! node_modules/@typescript-eslint/parser
npm ERR! dev @typescript-eslint/parser@"~4.31.2" from the root project
npm ERR! @typescript-eslint/parser@"^4.20.0" from eslint-config-next@11.1.2
npm ERR! node_modules/eslint-config-next
npm ERR! dev eslint-config-next@"11.1.2" from the root project
npm ERR! eslint-config-next@"^11.1.0" from @nrwl/next@12.9.0
npm ERR! node_modules/@nrwl/next
npm ERR! dev @nrwl/next@"12.9.0" from the root project
npm ERR! 1 more (@typescript-eslint/eslint-plugin)
npm ERR!
npm ERR! Could not resolve dependency: …Run Code Online (Sandbox Code Playgroud) 我想使用该reduce函数而不是这样做:
var result = '';
authors.forEach(
function(author) {
result += author.name + ', ';
}
);
console.log(result);
Run Code Online (Sandbox Code Playgroud)
所以在数组中authors有几个名字.现在我想用这个名字构建一个字符串,用逗号分隔(除了最后一个).
var result = authors.reduce(function (author, index) {
return author + ' ';
}, '');
console.log(result);
Run Code Online (Sandbox Code Playgroud) 我已经构建了一个带有单个文本输入的简单组件,下面是一个列表(使用语义ui).
现在我想使用箭头键浏览列表.
选择意味着将类添加active到项目中还是有更好的想法?
export default class Example extends Component {
constructor(props) {
super(props)
this.handleChange = this.handleChange.bind(this)
this.state = { result: [] }
}
handleChange(event) {
// arrow up/down button should select next/previous list element
}
render() {
return (
<Container>
<Input onChange={ this.handleChange }/>
<List>
{
result.map(i => {
return (
<List.Item key={ i._id } >
<span>{ i.title }</span>
</List.Item>
)
})
}
</List>
</Container>
)
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试获得一个语义ui(react)菜单列表,它应该与react路由器一起工作,这意味着我想使用Link组件react router
如果我用这个......
<Menu.Item name='profile'>
<Icon name='user' />
My profile
</Menu.Item>
Run Code Online (Sandbox Code Playgroud)
......它给了我结果:
<a class="item">
<i aria-hidden="true" class="user icon"></i>
My profile
</a>
Run Code Online (Sandbox Code Playgroud)
但我想得到类似的东西
<Link to='profile'>
<i aria-hidden="true" class="user icon"></i>
My profile
</Link>
Run Code Online (Sandbox Code Playgroud)
这个不起作用,因为语法错误:
<Menu.Item name='profile' as={ <Link to='profile' /> }>
<Icon name='user' />
My profile
</Menu.Item>
Run Code Online (Sandbox Code Playgroud) javascript reactjs semantic-ui react-router semantic-ui-react
是否可以在eslint中停用此错误?
Parsing error: 'import' and 'export' may only appear at the top level
Run Code Online (Sandbox Code Playgroud) 我正在尝试启动nodeJS应用程序,但我确实收到了错误
Error: The module '/Users/api/node_modules/bcrypt/lib/binding/bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Run Code Online (Sandbox Code Playgroud)
我已经运行npm install和npm rebuild.但仍然是同样的错误......
我正在尝试使用gitlab(docker)的auth配置我的docker注册表.
做docker login registry.website.com了给我一个401 Unauthorized错误:
Error response from daemon: login attempt to https://registry.website.com/v2/ failed with status: 401 Unauthorized
Run Code Online (Sandbox Code Playgroud)
在docker日志中我找到了
{ "level":"info","msg":"token signed by untrusted key with ID: \"IWNY:KT2H:YUN5:STQP:22LM:YNIU:RT4T:AZO7:TBVL:ZQ3I:Z4JZ:LA3T\"","time":"2018-12-17T23:36:03.538232467Z" }
{ [...] "level":"warning","msg":"error authorizing context: invalid token","service":"registry","source":"registry","time":"2018-12-17T23:36:03.53860308Z","version":"v2.6.2" }
Run Code Online (Sandbox Code Playgroud)
我的钥匙是通过做生成的
$ sudo openssl req -new -newkey rsa:4096 -subj "/CN=gitlab-issuer" -nodes -x509 -keyout registry-auth.key -out registry-auth.crt
$ sudo chmod 400 registry-auth.key
Run Code Online (Sandbox Code Playgroud)
在我的调试尝试中,我得到了不同的sha256摘要:
459b854f47c51bd94e0fd696cc35148cf93065df986abcc368cf13958373d298
459b854f47c51bd94e0fd696cc35148cf93065df986abcc368cf13958373
Run Code Online (Sandbox Code Playgroud)
正如@VDR所示,这是正常的,因为前30个字符被使用.因此,键应该没有问题.但为什么我会收到401错误?
这是我配置gitlab和注册表的方式:
docker gitlab(gitlab.rb)的配置使用key by
gitlab_rails['registry_key_path'] = "/certs/registry-auth.key"
Run Code Online (Sandbox Code Playgroud)
注册表配置有
auth.token.rootcertbundle: /root/certs/registry-auth.crt
Run Code Online (Sandbox Code Playgroud)
我不知道我在这里缺少什么......
对于链接 - 在JointJS图中 - 我试图实现本教程(http://jointjs.com/tutorial/constraint-move-to-circle)来移动链接上的标签,但我不明白在哪里放了ConstraintElementView.
ConstraintElementView
var constraint = label; // ???
var ConstraintElementView = joint.dia.ElementView.extend({
pointerdown: function(evt, x, y) {
var position = this.model.get('position');
var size = this.model.get('size');
var center = g.rect(position.x, position.y, size.width, size.height).center();
var intersection = constraint.intersectionWithLineFromCenterToPoint(center);
joint.dia.ElementView.prototype.pointerdown.apply(this, [evt, intersection.x, intersection.y]);
},
pointermove: function(evt, x, y) {
var intersection = constraint.intersectionWithLineFromCenterToPoint(g.point(x, y));
joint.dia.ElementView.prototype.pointermove.apply(this, [evt, intersection.x, intersection.y]);
}
});
Run Code Online (Sandbox Code Playgroud)
链接标签
paper.on({
/**
* Doubleclick on link: Add label for link
*/
'cell:pointerdblclick': function(cellView, …Run Code Online (Sandbox Code Playgroud) 如何为php json_encode() - 函数使用多个标志?
json_encode($array, JSON_PRETTY_PRINT, JSON_UNESCAPED_UNICODE);
Run Code Online (Sandbox Code Playgroud)
这不起作用 - 因为第一个标志将被完成,第二个标志将被忽略.
javascript ×5
reactjs ×2
docker ×1
ecmascript-6 ×1
eslint ×1
gitlab ×1
jointjs ×1
json ×1
lint ×1
node.js ×1
npm ×1
php ×1
react-router ×1
semantic-ui ×1