我们都知道,柔性属性是一个速记flex-grow
,flex-shrink
和flex-basis
属性.它的默认值是0 1 auto
.它的意思是:
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
Run Code Online (Sandbox Code Playgroud)
但我注意到,在很多地方flex: 1
都使用过.是简写1 1 auto
还是1 0 auto
?我无法理解它是什么意思?我没有在谷歌上搜索任何东西.
它是关于使用regexp作为分割符在字符串末尾进行分割
console.log('ab '.split(/\s*$/));
Run Code Online (Sandbox Code Playgroud)
输出:['ab','']
但是如果我删除结尾空间
console.log('ab'.split(/\s*$/))
Run Code Online (Sandbox Code Playgroud)
输出:['ab']
为什么第二个在输出中没有?
在 app.component.ts 中,我有一个名为 current 的属性。
export class appComponent {
current = 0;
}
Run Code Online (Sandbox Code Playgroud)
在我的一些方法中我改变了这个属性
previous() {
this.current -= 1
}
next() {
this.current += 1
}
Run Code Online (Sandbox Code Playgroud)
现在,我想在当前属性更改时运行一组命令。我可以通过在更改后附加这些命令来完成此操作。
previous() {
this.current -= 1;
this.runCommands();
}
next() {
this.current += 1;
this.runCommands();
}
Run Code Online (Sandbox Code Playgroud)
一切都很好。但是看吧,每次这个属性改变时调用这个方法似乎很混乱。我想要执行的操作是运行更改检测功能,运行我的命令,例如:
this.current.valueChanges.subscribe(() => this.runCommand());
Run Code Online (Sandbox Code Playgroud)
有可能用更简单的角度方式吗?
提前致谢
我有一个整数列表:
lists = [8,7,2]
Run Code Online (Sandbox Code Playgroud)
我希望它是:
result = 872
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式做到这一点:
result = 0
for count, i in enumerate(reversed(lists)):
result += i*(10**count)
Run Code Online (Sandbox Code Playgroud)
有用。但我认为应该有另一种更好更快的方法。提前致谢