而不是将动画附加到正在路由到的每个组件,例如在此StackOverflow答案中,或者在官方文档的第一部分中.一个例子:
在
hero-detail.component.ts:Run Code Online (Sandbox Code Playgroud)import { Component, OnInit } from '@angular/core'; import { fadeInOutAnimation } from "app/app-routing.animation"; @Component({ selector: 'app-home', templateUrl: './home.component.html', animations: [ fadeInOutAnimation(300) ] }) export class HomeComponent{ }在
app-routing.animation.ts:Run Code Online (Sandbox Code Playgroud)import { trigger, state, style, animate, transition } from '@angular/animations'; export const fadeInOutAnimation = function (fadeInTimeMS) { return trigger('fadeInOut', [ transition(':enter', [ // :enter is alias to 'void => *' style({ opacity: 0 }), animate(fadeInTimeMS, style({ opacity: 1 })) ]), …
我有一个结构:
struct ThreeDPoint {
x: f32,
y: f32,
z: f32
}
Run Code Online (Sandbox Code Playgroud)
我想在实例化之后提取三个属性中的两个:
let point: ThreeDPoint = ThreeDPoint { x: 0.3, y: 0.4, z: 0.5 };
let ThreeDPoint { x: my_x, y: my_y } = point;
Run Code Online (Sandbox Code Playgroud)
编译器抛出以下错误:
error[E0027]: pattern does not mention field `z`
--> src/structures.rs:44:9
|
44 | let ThreeDPoint { x: my_x, y: my_y } = point;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `z`
Run Code Online (Sandbox Code Playgroud)
在JavaScript(ES6)中,等效的解构将如下所示:
let { x: my_x, y: my_y } = point;
Run Code Online (Sandbox Code Playgroud) 使用kubectl apply -k,您可以覆盖资源配置(您已经定义)。你也可以创建资源吗?
在我的具体情况下,我想为开发环境创建一个本地卷。不过,我的基本文件夹中没有此资源。
\n\n我的文件夹结构是这样的:
\n\n\n\nRun Code Online (Sandbox Code Playgroud)\n~/someApp\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 base\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 deployment.yaml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 service.yaml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 overlays\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 development\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 cpu_count.yaml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 replica_count.yaml\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 volume.yaml <--- *Is this possible*?\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 production\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 cpu_count.yaml\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 replica_count.yaml\n
我想指定数组的其余部分应该如何显示,而不知道数组将有多少个值。我怎样才能实现这样的目标?(这里是游乐场版本):
type numStrArr = [number, ...string];
let arr: numStrArr = [1, 'hi', 'other string'];
Run Code Online (Sandbox Code Playgroud)
Type expected.然而,上面的代码在扩展运算符处抛出了错误。
我知道有人对此提出建议,但现在我怎样才能实现类似的行为呢?
Rust决定在模式中禁止float文字:完全允许匹配浮点文字值,不应该是#41255.它目前是一个警告,但在将来的版本中将是一个很难的错误.
我的问题是,如何使用以下代码实现等效?:
struct Point {
x: f64,
y: f64,
}
let point = Point {x: 5.0, y: 4.0};
match point {
Point {x: 5.0 , y} => println!("y is {} when x is 5", y), // Causes warning
_ => println!("x is not 5")
}
Run Code Online (Sandbox Code Playgroud)
现在不可能吗?我是否需要改变对模式的看法?还有另一种匹配方式吗?
我怎样才能解决我的.ts文件,每次我保存在一个文件WebStorm?
我知道我可以tslint --fix在保存后跑步.我也知道我可以⌥⏎+ ⏎在文件中的当前错误,并将解决该错误.但我已经习惯了不同的样式指南,它可以节省我很多时间来自动修复这些样式lint错误:
我在WebStorm中找不到相关设置:
我也完全愿意使用不同的cli工具来实现保存时的自动创作.
这是我尝试过的行为:
struct Matrix(f32, f32, f32, f32);
let matrix = Matrix(1.1, 1.2, 2.1, 2.2);
matrix.len(); // expected `4`
Run Code Online (Sandbox Code Playgroud)
这会产生错误:
struct Matrix(f32, f32, f32, f32);
let matrix = Matrix(1.1, 1.2, 2.1, 2.2);
matrix.len(); // expected `4`
Run Code Online (Sandbox Code Playgroud)
std::iter::ExactSizeIterator看起来是一个不错的候选人,但我仍然不知道如何实施
在尝试反向时Matrix,我意识到不要像这样干巴巴地列出矩阵的反向索引:
fn reverse(matrix: Matrix) -> Matrix {
return Matrix(matrix.3, matrix.2, matrix.1, matrix.0)
}
Run Code Online (Sandbox Code Playgroud)
我也许可以按Matrix相反的顺序迭代。我看到如何迭代或映射元组?并认为这很复杂。如果能够获得元组的长度,就可以解决“如何迭代或映射元组?”这一问题。有一个更简单的解决方案。显然,我可以只使用“4”作为长度,但是如果我不使用结构体而是使用未知长度的元组怎么办?
我已阅读如何使用索引位置迭代 Vec<T>?答案是enumerate在for-loop 中使用。
但是,如果我不使用这样的for-loop:
fn main() {
let v = vec![1; 10]
.iter()
.map(|&x| x + 1 /* + index */ ) // <--
.collect::<Vec<_>>();
print!("v{:?}", v);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能在上面的闭包中获得索引?
我如何在typeof BaseListComponent下面指定?
下面的代码引发以下错误:
类型'
({ title: string; component: typeof QuestionsListComponent; } | { title: string; component: ...'不能分配给类型'{ title: string; component: typeof BaseListComponent; }[]'.
摘抄:
abstract class BaseListComponent {
protected title
}
class WeatherListComponent extends BaseListComponent {}
class QuestionsListComponent extends BaseListComponent {}
let containerItems: Array<{title: string, component: typeof BaseListComponent}>;
containerItems = [
{title:'TypeScript', component: QuestionsListComponent},
{title:'Angular2', component: QuestionsListComponent},
{title:'Weather', component: WeatherListComponent}
]
Run Code Online (Sandbox Code Playgroud)
PS这是一个角度应用程序的简化摘录,所以这种疯狂背后有逻辑.
我正在开发一个角度为4.1.0的MEAN项目.
在我的localhost上,一切正常,没有错误.但是,当我部署到服务器时,检索具有8个以上问题 - 答案对的用户会导致在角度的http模块触发的xhr请求上出现net :: ERR_CONNECTION_CLOSED错误.
我托管的数字海洋小滴使用nginx反向代理并使用letsencrypt SSL证书.我试过了:
client_max_body_size至20M在nginx的配置文件large_client_header_buffers'size'增加到128knginx配置文件中其他重要事实:
GET请求qapairs?jwt=ey../var/log/nginx/error.log显示的失败请求/var/log/nginx/access.log如下:
89.15.159.19 - - [08/May/2017:14:25:53 +0000] "-" 400 0 "-" "-"
89.15.159.19 - - [08/May/2017:14:25:53 +0000] "-" 400 0 "-" "-"
Run Code Online (Sandbox Code Playgroud)请指出我可能的方向.
登录到只有7个问题答案对的帐户后

然后,在转到mlab.com并手动将另一个问题答案对添加到同一帐户然后刷新页面(注意现在的问题数量为8)

最后,登录和退出同一帐户后(注意xhr请求qapairs?jwt=ey...返回失败状态)

在/ etc/nginx的/启用的站点 - /默认
Run Code Online (Sandbox Code Playgroud)# HTTP — redirect all traffic to HTTPS server { listen 80; listen [::]:80 default_server …
Rust是否有一个功能,我可以创建定义特征上可能不存在的方法?
我意识到这Option可以用来处理可能不存在的属性,但我不知道如何用方法实现相同.
在TypeScript中,问号表示方法可能不存在.以下是RxJs的摘录:
export interface NextObserver<T> {
next?: (value: T) => void;
// ...
}
Run Code Online (Sandbox Code Playgroud)
如果Rust中不存在此功能,那么应该如何考虑处理对象,程序员不知道方法是否存在?恐慌?
我想取一个向量的最后两个数字.为什么我不能两次反转迭代器?
fn main() {
let double_reversed = &vec![1, 2, 3, 4, 5, 6, 7, 8, 9]
.into_iter()
.rev()
.take(2)
.rev()
.collect();
println!("{}", double_reversed); // expected 8, 9
}
Run Code Online (Sandbox Code Playgroud)
错误消息是:
error[E0277]: the trait bound `std::iter::Take<std::iter::Rev<std::vec::IntoIter<{integer}>>>: std::iter::DoubleEndedIterator` is not satisfied
--> src/main.rs:6:10
|
6 | .rev()
| ^^^ the trait `std::iter::DoubleEndedIterator` is not implemented for `std::iter::Take<std::iter::Rev<std::vec::IntoIter<{integer}>>>`
error[E0599]: no method named `collect` found for type `std::iter::Rev<std::iter::Take<std::iter::Rev<std::vec::IntoIter<{integer}>>>>` in the current scope
--> src/main.rs:7:10
|
7 | .collect();
| ^^^^^^^
|
= note: the …Run Code Online (Sandbox Code Playgroud) rust ×6
typescript ×3
angular ×2
tuples ×2
types ×2
webstorm ×2
animation ×1
class ×1
custom-type ×1
http2 ×1
intellisense ×1
interface ×1
iterator ×1
javascript ×1
jsdoc ×1
kubernetes ×1
kustomize ×1
match ×1
mongodb ×1
nginx ×1
node.js ×1
ssl ×1
templating ×1
traits ×1
tslint ×1