八巷

文章 评论 浏览 28

八巷 2025-02-20 18:35:32

通常,从模板调用方法总是一个坏主意(因为Angular无法预测该方法的返回值是否已更改),并且在函数不是纯的情况下,我们无法用解决问题。更改teeteTectionsTrategy.onpush 管道,因此我可以建议两个解决方案:

  1. 计算 maxheight cardComponent

  2. 预定所有值 domaindetailscomponent ,例如:

<ng-container *ngFor="let line of catArray; let i = index">
  <div class="grid_column">
    <app-card
      *ngFor="let cat of line; let j = index"
      [category]="cat"
      [maxWidth]="450"
      [maxHeight]="sizes[i][j]">
    </app-card>
  </div>
</ng-container>
catArray: CategoryModel[][] = [];
sizes: number[][] = [];

constructor() {
  this.divideArray(this.domain.categories, this.domain.categories.length / 3);
  this.sizes = this.catArray.map((line) => line.map((item) => this.randomSize()));
}

Calling a method from a template is always a bad idea in general (because Angular cannot predict whether the return value of the method has changed), and in the case where the function is not pure, we can not resolve the problem with ChangeDetectionStrategy.OnPush and Pipe, so I can suggest two solutions:

  1. Calculate maxHeight inside CardComponent.

  2. Pre-define all values inside DomainDetailsComponent, for example, like this:

<ng-container *ngFor="let line of catArray; let i = index">
  <div class="grid_column">
    <app-card
      *ngFor="let cat of line; let j = index"
      [category]="cat"
      [maxWidth]="450"
      [maxHeight]="sizes[i][j]">
    </app-card>
  </div>
</ng-container>
catArray: CategoryModel[][] = [];
sizes: number[][] = [];

constructor() {
  this.divideArray(this.domain.categories, this.domain.categories.length / 3);
  this.sizes = this.catArray.map((line) => line.map((item) => this.randomSize()));
}

随机功能使组件更改时单击

八巷 2025-02-20 17:13:51

您可以使用子集,如下:

rn = ind

rn[] <- rownames(m)[ind]

     [,1] [,2]
[1,] "A"  "A" 
[2,] "B"  "B" 
[3,] "C"  "F" 
[4,] "D"  "G" 
[5,] "E"  "H" 

You can use subsetting as follow:

rn = ind

rn[] <- rownames(m)[ind]

     [,1] [,2]
[1,] "A"  "A" 
[2,] "B"  "B" 
[3,] "C"  "F" 
[4,] "D"  "G" 
[5,] "E"  "H" 

如何打印出行名而不是​​其索引?

八巷 2025-02-20 16:47:32

导航到WordPress仪表板 - 设置 - 永久链接
您可以重写永久链接

Navigate to Wordpress Dashboard - Settings - Permalinks
and you can rewrite the Permalinks

更改WordPress页面链接为动态

八巷 2025-02-20 07:10:28
awk '{printf("print(\"Hi\");\nprint(\"Hello\");\nprint(\"%s\"); # here\n\n",$0)}' input_file.txt

更新:据我了解您的评论,您需要一个模板

template-file:
bla
bla bla
bla %NAME% bla
bla

script:
IFS=
\n'
for i in `cat names`; do
sed "s/%NAME%/$i/" template-file
done
awk '{printf("print(\"Hi\");\nprint(\"Hello\");\nprint(\"%s\"); # here\n\n",$0)}' input_file.txt

UPDATE: as I understand your comment, you need a template

template-file:
bla
bla bla
bla %NAME% bla
bla

script:
IFS=
\n'
for i in `cat names`; do
sed "s/%NAME%/$i/" template-file
done

生成只有一行不同的代码副本

八巷 2025-02-18 23:34:21

我给你一个示例供您参考。

 $('tbody tr.parent-tr').on('change', ':checkbox', function () {
    let tbody=$(this).parents("tbody");
    tbody.children("tr.child-tr").find(":checkbox").attr('checked', $(this).is(':checked'));
 });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
    <tbody>
        <!-- parent -->
        <tr class="parent-tr">
            <td>Parent 1<input type="checkbox" name="subject" id="subject"></td>
            <td colspan="3"></td>
        </tr>
        <!-- child -->
        <tr class="child-tr">
            <td>Child of Parent 1<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 1<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 1<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
    </tbody>
    <tbody>
        <!-- parent -->
        <tr class="parent-tr">
            <td>Parent 2<input type="checkbox" name="subject" id="subject"></td>
            <td colspan="3"></td>
        </tr>
        <!-- child -->
        <tr class="child-tr">
            <td>Child of Parent 2<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 2<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 2<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
    </tbody>
</table>

I give you an example for your reference.

 $('tbody tr.parent-tr').on('change', ':checkbox', function () {
    let tbody=$(this).parents("tbody");
    tbody.children("tr.child-tr").find(":checkbox").attr('checked', $(this).is(':checked'));
 });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
    <tbody>
        <!-- parent -->
        <tr class="parent-tr">
            <td>Parent 1<input type="checkbox" name="subject" id="subject"></td>
            <td colspan="3"></td>
        </tr>
        <!-- child -->
        <tr class="child-tr">
            <td>Child of Parent 1<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 1<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 1<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
    </tbody>
    <tbody>
        <!-- parent -->
        <tr class="parent-tr">
            <td>Parent 2<input type="checkbox" name="subject" id="subject"></td>
            <td colspan="3"></td>
        </tr>
        <!-- child -->
        <tr class="child-tr">
            <td>Child of Parent 2<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 2<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
        <tr class="child-tr">
            <td>Child of Parent 2<input type="checkbox" name="ticker" id="ticker"></td>
        </tr>
    </tbody>
</table>

如何使用jQuery在HTML表中使子TR TR输入值为true?

八巷 2025-02-18 20:47:21

回调OnDisableStoredPaymentMethod(...)也需要包含在Dropin中。根据文档:OnDisableStoredPaymentMethod(StordPaymentMethodID,Resolve,recult)删除了存储的付款方法(需要在homecontroller.cs中工作以支持 /disable端点)。当购物者删除存储的付款方式时,这就是称为。要删除所选的付款方式,请使用StorePaymentMethodID进行A /禁用请求。然后根据 /禁用响应来调用Resolve()或recond()。

有关更多信息( https://docs.adyen。 com/inline-payments/dokenization/toking-tokens#disable存储details )和/或高级用例,您可以在此处找到更多信息: https://docs.adyen.com/online-payments/web-drop-in/web-drop-in/optional-configuration

希望有帮助!

编辑/添加示例:

const dropin = checkout
  .create('dropin', {
    showRemovePaymentMethodButton: true,
    onDisableStoredPaymentMethod(storedPaymentMethodId, resolve, reject) {
      console.log('hey there');
    }
  })
  .mount('#dropin-container');

The callback onDisableStoredPaymentMethod(...) also needs to be included in the Dropin. According to the documentation: onDisableStoredPaymentMethod(storedPaymentMethodId, resolve, reject) removes the stored payment method (requires work in the HomeController.cs to support the /disable endpoint). This is called when a shopper removes a stored payment method. To remove the selected payment method, make a /disable request using the storedPaymentMethodId. Then call either resolve() or reject(), depending on the /disable response.

For more information (https://docs.adyen.com/online-payments/tokenization/managing-tokens#disable-stored-details) and/or advanced use-cases, you can find more information here: https://docs.adyen.com/online-payments/web-drop-in/optional-configuration

Hope that helped!

Edit/added example:

const dropin = checkout
  .create('dropin', {
    showRemovePaymentMethodButton: true,
    onDisableStoredPaymentMethod(storedPaymentMethodId, resolve, reject) {
      console.log('hey there');
    }
  })
  .mount('#dropin-container');

允许删除Adyen Drop的保存信用卡信息

八巷 2025-02-18 14:13:24

对我来说,我添加了一个状态变量作为数据元元素的键,并包括一个事件侦听器(resetFilters())以修改变量(键),从而每次都会触发反应以更新和呈现数据杂志元素。

 const [muiTableKey, setMuiTableKey] = React.useState<any>(1);
..................................
  const resetFilters = async () => {
    setMuiTableKey(muiTableKey+1)
  }
..................
<DataGrid 
        rows={items}
        columns={columns}
        ... blah blah
        key={muiTableKey}
      />

For me, I added a state variable as a key to the DataGrid element and included an event listener (resetFilters()) to modify the variable (key), thereby triggering React to update and render the DataGrid element with the fresh data every time.

 const [muiTableKey, setMuiTableKey] = React.useState<any>(1);
..................................
  const resetFilters = async () => {
    setMuiTableKey(muiTableKey+1)
  }
..................
<DataGrid 
        rows={items}
        columns={columns}
        ... blah blah
        key={muiTableKey}
      />

如何清除MUI React DataGrid中的所有应用过滤器?

八巷 2025-02-17 16:54:27

根据您的评论,如果您希望用户收到的响应不包含 _id 您可以:

  • 获取文档
  • 删除 _id 属性,并在没有 _id (或创建一个新对象以避免问题)。

一个简短的例子可能是:

let responseDoc = await Admin.findOne({ _id: id });
delete responseDoc["_id"]
// responseDoc is now ready for use. Note that if I am not mistaken it is still a document.

Based on your comment, if you want the response the user receives to not contain the _id you can:

  • Get the document
  • Remove the _id property and return this object without the _id (Or create a new object to avoid problems).

A brief example could be:

let responseDoc = await Admin.findOne({ _id: id });
delete responseDoc["_id"]
// responseDoc is now ready for use. Note that if I am not mistaken it is still a document.

架构选项_id:false和文档在保存错误发生之前必须具有_id

八巷 2025-02-17 07:40:22

在这里,您可以 - https://allthings.how how of /sourved-this-this-extension-violates-the-chrome-web-web-store-policy/

我面临类似的问题,我通常会重新安装扩展名以使其正常工作。尝试上面的链接。

Here you go - https://allthings.how/solved-this-extension-violates-the-chrome-web-store-policy/

I was facing a similar issue, I usually reinstall the extension to make it work. Try the link above.

Salesforce LWC编辑器Chrome扩展错误

八巷 2025-02-16 13:15:34

当然可以在文本组件中显示面板大小。您可以使用 setText(String t)方法来设置 jtextfield jtextarea 。尝试以下操作:

String width = myPanel.getWidth();
myTextField.setText(width);

它将在JTEXTFIELD中向用户显示面板的宽度。 (或者您可以将文本字段替换为您喜欢的任何文本组件)

您还可以查看 java教程 如何使用顶级容器 Java教程是Swing Developers的出色官方文件。

It is certainly possible to display the panel size in a text component. You can use setText(String t) method to set the display text of a JTextField or a JTextArea. Try this:

String width = myPanel.getWidth();
myTextField.setText(width);

It will display the width of the panel to the user in a JTextField. (Or you can replace the text field to any text components you like)

You can also take a look at these two sections in the Java Tutorial: How to use Top-Level containers and Using Text Components. The Java Tutorial is a great official document for Swing developers.

使用GetWidth();?

八巷 2025-02-16 07:25:32

您可以重复1或2次匹配1或更多大写字符[AZ],然后进行下划线。

在替换中使用一个空字符串。

(?:[A-Z]+_){1,2}

You can repeat 1 or 2 times matching 1 or more uppercase chars [A-Z] followed by an underscore.

In the replacement use an empty string.

(?:[A-Z]+_){1,2}

Regex demo

从字符串中提取用户名

八巷 2025-02-15 22:07:12

1)是的,但也许不在Windows和/或.bat文件上。例如,当您运行等同于以下窗口的窗口时会发生什么:

import subprocess

test_string = 'Bill said "Hi!"'

cmd = ["./myprog.py",
       test_string
       ]

p = subprocess.Popen(cmd)
p.wait()

myprog.py:

#!/usr/bin/env python

import sys

print '"{}"'.format(sys.argv[1])

2)好吧,以下内容似乎有些模棱两可:

"Bill said "Hi!""

引用的字符串是:

"Bill said " 

接着是未引用的字符串:

Hi!

随后是引用的空白字符串:

""

1) Yes, but maybe not on windows and/or with a .bat file. For example, what happens when you run the windows equivalent of this:

import subprocess

test_string = 'Bill said "Hi!"'

cmd = ["./myprog.py",
       test_string
       ]

p = subprocess.Popen(cmd)
p.wait()

myprog.py:

#!/usr/bin/env python

import sys

print '"{}"'.format(sys.argv[1])

2) Well, the following seems a bit ambiguous:

"Bill said "Hi!""

Is that the quoted string:

"Bill said " 

followed by the unquoted string:

Hi!

followed by a quoted blank string:

""

?

通过使用Python的参数,包括双引号到子过程

八巷 2025-02-15 21:22:37

在这里,您还有另一种选择使用指针:

a = [ 0, 1, 2 ]
i = 0
l = len(a)
while True:
  out = []
  for j in range(i, i+l):
    out.append(a[j%l])
  print(out)
  i=(i+1)%l

输出:

[0, 1, 2]
[1, 2, 0]
[2, 0, 1]
[0, 1, 2]
[1, 2, 0]
[2, 0, 1]

Here you have another alternative using pointers:

a = [ 0, 1, 2 ]
i = 0
l = len(a)
while True:
  out = []
  for j in range(i, i+l):
    out.append(a[j%l])
  print(out)
  i=(i+1)%l

Output:

[0, 1, 2]
[1, 2, 0]
[2, 0, 1]
[0, 1, 2]
[1, 2, 0]
[2, 0, 1]

如何通过&#x2B; 1偏移每个循环无限地迭代列表

八巷 2025-02-15 11:53:44

似乎可以在C ++ 14:

https://en.wikipedia .org/wiki/c%2B%2B14#Runtime-sized_one_dimensional_arrays

更新:它没有将其纳入C ++14。

Seems it will be available in C++14:

https://en.wikipedia.org/wiki/C%2B%2B14#Runtime-sized_one_dimensional_arrays

Update: It did not make it into C++14.

为什么AREN&#x27; t变量长度阵列部分C&#x2B;&#x2B;标准?

八巷 2025-02-15 04:58:05

调用 destroy(gameObject)应该起作用。对我而言,危险的线路是,

hit.transform.gameObject.GetComponent<BasicAI>().damage((int)Random.Range(damageAmount[0], damageAmount[1]), sender.transform);

如果GameObject没有 basicai 组件,您将遇到NullReferenceException。当时这不会使您的游戏崩溃。但是,它将不再执行 update()的其余部分,并在控制台中向您显示错误。

对于具有特定组件的对象做出假设很诱人,然后您可以将其调用其中一种方法。更好的防御能力可能会更好。例如,将其更改为

foreach(var hit in hitted) {
    var basicAI = hit.transform.gameObject.GetComponent<BasicAI>();
    if(basicAI != null)
    {
        basicAI.damage((int)Random.Range(damageAmount[0], damageAmount[1]), sender.transform);
    }
    else
    {
        Debug.LogError("Expected GameObject to have a BasicAI component, but it didn't!");
    }
}

,但是即使您决定不这样做,也要在遇到这样的奇怪行为时密切注意您的控制台。

The call to Destroy(gameObject) should work. The dangerous line that stands out to me is

hit.transform.gameObject.GetComponent<BasicAI>().damage((int)Random.Range(damageAmount[0], damageAmount[1]), sender.transform);

If the gameObject doesn't have a BasicAI component, you'll run into a NullReferenceException. This in Unity won't crash your game right there and then. It will however no longer execute the rest of the Update(), and show you an error in the console.

It's tempting to make assumptions about an object having a particular component, upon which you can then call one of its methods. It's probably better to be a bit more defensive. For example, change it to

foreach(var hit in hitted) {
    var basicAI = hit.transform.gameObject.GetComponent<BasicAI>();
    if(basicAI != null)
    {
        basicAI.damage((int)Random.Range(damageAmount[0], damageAmount[1]), sender.transform);
    }
    else
    {
        Debug.LogError("Expected GameObject to have a BasicAI component, but it didn't!");
    }
}

But even if you decide not to do that, pay close attention to your console whenever you encounter strange behaviour like this.

在Unity 3D中,为什么在这里销毁(GameObject)不起作用?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文