我正在开发一个应用程序,我希望实现这样的事情:如果用户从一个组件离开并进入其他组件,那么在其他组件的ngOnInit方法中,chrome浏览器应该全屏显示与按Fn + F11键时相同的全屏.
任何帮助或参考表示赞赏.
我有一个 data.json 文件,如下所示。
[
{"value":1},
{"value":2},
{"value":3},
{"value":3}
]
Run Code Online (Sandbox Code Playgroud)
& 我正在使用 Http 来获取数据。数据正常传输,但是如果我的服务器关闭了,那么它会抛出错误,我想向用户显示一些自定义消息而不是该错误。下面是我获取数据的函数。
data: any;
getData() {
this.http.get('http://localhost/php/data.json').subscribe((res) => {
this.data = res;
console.log(this.data);
})
}
ngOnInit() {
this.getData();
}
Run Code Online (Sandbox Code Playgroud) 大家好,我有阵列,我需要执行各种操作,如总和,平均值.所有这三个都实现了,现在我需要找到数组中的最小值和最大值.我坚持下面是代码.
以下是TS部分
people: Array<number> = [1, 2, 3, 4, 5];
total: number = 0;
arrayLength: number = this.people.length;
average: number = 0;
sum() {
for (var i in this.people) { this.total += this.people[i]; }
}
ngOnInit() {
this.sum();
this.average = (this.total / this.arrayLength);
}
Run Code Online (Sandbox Code Playgroud)
下面是HTML部分
<span *ngFor="let p of people" style="font-size:18px">{{p}} </span><br><br>
<button >Quantity</button> = {{arrayLength}}<Br><br>
<button >Average</button> = {{average}}<Br><br>
<button >Sum</button> <span *ngIf="sumShow"> = {{total}}</span><Br><br>
Run Code Online (Sandbox Code Playgroud) 我经过24小时的搜索,发现自己的问题很琐碎(不是R的新手),至今还没有结出硕果。所以请帮帮我。我有一个数据框,希望将其拆分为两个。数据如下所示:
d1 d2 d3 d4 p1 p2 p3 p4
30 40 20 60 1 3 2 5
20 50 40 30 3 4 1 5
40 20 50 30 2 3 1 4
Run Code Online (Sandbox Code Playgroud)
这是我想要的样子;
$d
d1 d2 d3 d4
30 40 20 60
20 50 40 30
40 20 50 30
$p
p1 p2 p3 p4
1 3 2 5
3 4 1 5
2 3 1 4
Run Code Online (Sandbox Code Playgroud)
我已经在线尝试了大多数命令和示例,但是它们似乎都在沿行拆分数据,例如:
split(1:3, 1:2)
Run Code Online (Sandbox Code Playgroud)
即使使用索引,我怎么也要从后四列中拆分出前四列?
我想更改侧边栏中应用优惠券的位置而不是选项卡部分。我已经在结账页面添加了一个自定义选项卡,该选项卡已基本完成。现在我只需要侧边栏中的“应用折扣代码”部分。
我当前的 checkout_index_index.xml 看起来像这样
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<!-- added custom step -->
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<!-- The new step you add -->
<item name="my-new-step" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/my-step-view</item>
<!--To display step content before shipping step "sortOrder" value should be < 1-->
<!--To display step content between shipping step and payment step 1 < "sortOrder" < 2 -->
<!--To display step …Run Code Online (Sandbox Code Playgroud)