当不在同一DOM元素中时,应该可以从一个控制器派遣事件并在另一个控制器中读取它。
当您从JavaScript派遣事件时,它会将DOM树泡泡到window
。您可以使用@Window
操作描述符来收听全局事件,以捕获所有在控制器的DOM树外面冒泡的事件。
请参阅
- https://stimulus.hotwired.dev/reference/reference/referenion/referenion/actions #global-ections#global-events
- https://developer.mozilla.org/en-us/docs/web/web/api/eventtarget/addeventlistlistlistener#parameters
您想要的事件,但是作为基本设置,您需要在数据操作中添加@window
。
示例
此处是一个工作端到端示例,而不是涡轮链接,其中表控制器不是添加行按钮的父母(这是同级)。使用窗口事件侦听器方法,我们可以在DOM树之外聆听事件。
在您的表控制器中收到事件后,类方法应可以访问该控制器的 nister 而无需问题。
如果要访问原始触发按钮的目标元素,则可以通过event.target
进行此操作。
<main>
<table data-controller="table" data-action="table-action:add@window->table#show">
<thead>
<tr>
<th data-table-target="status"></th>
</tr>
</thead>
<tr data-table-target="row">
<td>Item 1</td>
</tr>
<tr data-table-target="row">
<td>Item 2</td>
</tr>
<tr data-table-target="row">
<td>Item 3</td>
</tr>
<tr data-table-target="row">
<td>Item 4</td>
</tr>
</table>
<div>
<button data-controller="table-action" data-action="table-action#add"
data-table-action-url-param="https://path.to.tables/">
Add row
</button>
</div>
</main>
import { Controller } from '@hotwired/stimulus';
class TableController extends Controller {
static targets = ['row', 'status'];
show({ detail: { url } = {}, target }) {
console.log('event.target - the button that triggered the click', event.target);
if (url) {
const rowCount = this.rowTargets.length;
this.statusTarget.innerText = `Request from: ${url}, there are ${rowCount} rows.`;
}
}
}
export default TableController;
import { Controller } from '@hotwired/stimulus';
class TableActionController extends Controller {
add({ params }) {
this.dispatch('add', {
detail: { ...params },
bubbles: true,
cancelable: false,
});
}
}
export default TableActionController;
尝试一下:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
好吧,一种方法是使用-split
运算符,或者仅获取损坏字符串的 first 的方法,并检查它是否包含下划线字符(_
);因为这似乎遵循命名计划。
Get-ChildItem |
ForEach-Object -Process {
$destination = $_.Name.Split('-')[0]
if ($destination -match "_") {
Move-Item -LiteralPath $_.FullName -Destination "D:\share\$destination" -WhatIf
}
}
鉴于您不想移动其他文件,这只会移动具有相同启动的文件。
删除Whatif
安全性公共参数一旦您决定了结果。
请勿使用Laravel检测Laravel从您的服务器资源中消耗多少资源,而是使用服务器监视工具。
htop
是一个非常好的命令,我们可以用来检测哪些应用程序使用的服务器最多,多少!
现在,如果您对服务器良好 https://grafana.com/grafana.com/grafana/dashboards/ 检测RAM的使用等...
有一个很好的文档,但是如果您遇到任何麻烦,请发表评论,我将为您提供两个应用程序的服务器安装!
谢谢
所讨论的代码是指官方参考每个列名。
在我的研究阶段,找不到更改标头中每一列颜色的能力。
更新
要设置单元单元的背景颜色,颜色设置在行索引和列名称上。准备一个列表,从数据框架中进行一行,然后使用该行的内容作为辅助循环过程创建背景颜色的字典。添加到列表中创建的字典。
c_list = []
cols = ['Date', 'Region', 'Temperature', 'Humidity', 'Pressure']
for row in df_color.itertuples():
for i in range(len(cols)):
color_dict = {}
color_dict.update(
{
'if':{'row_index': row[0], 'column_id': cols[i]},
'backgroundColor': row[i+1]
}
)
c_list.append(color_dict)
app = Dash(__name__)
app.layout = dash_table.DataTable(
data=df.to_dict('records'),
columns=[{'id': c, 'name': c} for c in df.columns],
style_data_conditional=c_list
)
if __name__ == '__main__':
app.run_server(debug=True)
对象
类型只是本机JS 对象
。它仅具有与本机对象
关联的功能和键。
因此,如果您尝试访问对象
类型的属性,则会丢弃错误。
let b: object = {foo: 123};
b.foo; // Property 'foo' does not exist on type 'object'.(
但是,您可以使用{[键:字符串]:Any}
进行同样的操作
let a: {[key: string]: any} = {foo: 123};
a.foo;
。
实际上,记录
类型被声明为键入记录&lt; k扩展字符串|数字|符号,t&gt; = {[p in K]:t; }
使用SSC使用rangestat
考虑此模拟:
. webuse grunfeld, clear
. rangestat (count) invest (sd) invest, int(year -2 0) by(company)
. list year invest* if company == 1
+--------------------------------------+
| year invest invest~t invest_sd |
|--------------------------------------|
1. | 1935 317.6 1 . |
2. | 1936 391.8 2 52.46731 |
3. | 1937 410.6 3 49.173296 |
4. | 1938 257.7 3 83.381305 |
5. | 1939 330.8 3 76.474459 |
|--------------------------------------|
6. | 1940 461.2 3 103.08574 |
7. | 1941 512 3 93.468577 |
8. | 1942 448 3 33.790726 |
9. | 1943 499.6 3 33.941912 |
10. | 1944 547.5 3 49.761464 |
|--------------------------------------|
11. | 1945 561.2 3 32.343625 |
12. | 1946 688.1 3 77.523807 |
13. | 1947 568.9 3 71.147171 |
14. | 1948 529.2 3 82.698164 |
15. | 1949 555.1 3 20.154985 |
|--------------------------------------|
16. | 1950 642.9 3 59.592155 |
17. | 1951 755.9 3 100.66322 |
18. | 1952 891.2 3 124.31678 |
19. | 1953 1304.4 3 285.74248 |
20. | 1954 1486.7 3 305.11956 |
+--------------------------------------+
这种错误就是为什么我喜欢打字稿;)
编译器足够聪明,可以理解form.current
可以包含表单,也可以是null
,所以它是键入为htmlformelement | null
。
在您的sendemail
函数中,您不会以任何方式考虑这种情况,因此编译器大喊大叫,发牢骚,完全正确!
您必须考虑form.current
为null的情况:
const sendEmail = (e) => {
e.preventDefault();
const currentForm = form.current;
// this prevents sending emails if there is no form.
// in case currentForm cannot possibly ever be null,
// you could alert the user or throw an Error, here
if (currentForm == null) return;
// the compiler is smart enough to know that currentForm here is of type HTMLFormElement
emailjs.sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', currentForm, 'YOUR_PUBLIC_KEY')
.then((result) => {
console.log(result.text);
}, (error) => {
console.log(error.text);
});
};
我根据几个月的评论写了这个脚本。如果您没有给出另一个示例,很难理解您想使用locarray
。
locArray = [
[(1134, 604), (1134, 605)], # 0
[(1135, 604), (1135, 605)], # 1
[(1134, 605), (1135, 605)], # 2
[(1135, 605), (1134, 605)], # 3
[(1136, 605), (1135, 605)], # 4
[(1135, 606), (1135, 605)], # 5
[(1153, 921), (1153, 922)], # 6
[(1154, 921), (1153, 921)], # 7
[(1153, 922), (1153, 921)] # 8
]
# pairs is an array of pairs: [(x, y), ..., (x, y)]
#
# It checks if, from coord z is inside
# any of the pairs from the pairs array.
def coordInside(pairs, coord):
for pair in pairs:
if (coord == pair[0] or coord == pair[1]):
return True
return False
# Seeks out for every created category, from pair (a, b),
# if a or b is listed inside any category array.
#
# If no category is found, return -1
def findCategory(categories, pair):
index = 0
for category in categories:
if (coordInside(category, pair[0]) or coordInside(category, pair[1])):
return index
index += 1
return -1
# Categorizes by column order: [0, 1] all x-coordinates, then all y-coordinates.
def categorizeByColumns(array, cols=[0]):
categories = []
# For every column
for col in cols:
# For every row of the array:
for row in array:
# Retrieve the pair from the current row and column
pair = row[col]
# Get the current Category
index = findCategory(categories, pair)
# If no Category exists
if (index == -1):
# Create one and append to categories array
categories.append([pair])
# If the Category exists, append pair given it's not a duplicate
elif (pair not in categories[index]):
categories[index].append(pair)
return categories
# Generates the desired output you want
print(categorizeByColumns(locArray, [0, 1]))
这是输出:[((1134,604),(1135,604),(1134,605),(1135,605),(1136,605),(1135,606)],(1153 ,921),(1154,921),(1153,922)]]
权重可以下载为:
from tensorflow.keras.applications import resnet
base_cnn = resnet.ResNet50(
weights="imagenet", input_shape=target_shape + (3,), include_top=False
)
base_cnn.save("weights.h5")
然后加载保存的权重:
from tensorflow.keras.models import load_model
base_cnn=load_model('weights.h5')
赔偿是一个很好的举动,因为将大文件写入S3比编写小文件更好。
坚持将您的所有文件写入S3时,您会放慢速度。因此,您将数据写给S3两次。
S3是用于大型,缓慢,廉价的存储空间。不是要快速移动数据。如果您想迁移数据库 aws> aws具有该工具,值得研究它们。即使这样,您也可以将文件移至S3中。
S3写入存储桶,并通过文件路径确定存储桶,它使用尾部变化来分配&amp;自动拆分桶。 (/heres/some/wariation/at/th the/tail1,/heres/some/wariation/at/the/tail2)在这里是您的瓶颈。要获取多个存储桶,请将文件更改为文件路径的头部。(/head1/variation/isfaster/,/head2/variation/iSfaster/)
- 尝试删除
persist
。 (至少将cache()
视为较便宜的替代方案。 - 保持待机的范围
- 不同,以改变文件路径的头部,以获取更多存储桶。
- 考虑重新设计将数据推入S3使用REST API多个PART将数据推入S3上传。
发送率配置IE应该在客户端进行。
我认为您不会使用“纯”卷发,而是它将是某种脚本/应用程序。因此,您的节流需要在那里完成。
您可能需要在内部/etc/apache2/apache2/ site-abailable 内添加conf(test.watermaps-eg.com.conf)文件
在运行命令之前
sudo a2ensite test.watermaps-eg.com
// 运行JavaScript时用户完成时用户完成输入而不是键上吗?
// Run javascript function when user finishes typing instead of on key up?
延迟输入上的JavaScript,因此输入到搜索字段的每个字符确实会发射功能