眼泪都笑了

文章 评论 浏览 25

眼泪都笑了 2025-02-20 18:29:49

问题是,在添加新的元素之前,请在匹配元素上注册“点击事件”的事件侦听器。

一个简单的解决方案是没有实际按钮的事件侦听器,而是将其绑起来进行文档,然后在按钮上查找适当的类。

这个答案非常基本,只是为了证明这个概念。如果您注意到事件侦听器后的按钮已添加到DOM,但仍然可以使用。

document.addEventListener("click",function(e){
   let btn = e.target;
   if(btn.className.includes("increase")){
     console.log("increase")
   }
   else if(btn.className.includes("decrease")){
     console.log("decrease")
   }
});
let dest = document.querySelector("#dest");
dest.innerHTML = '<button class="increase">Increase</button><button class="decrease">Decrease</button>';
<div id="dest"></div>

The problem is the event listeners for the click events are being registered to the matching elements before you add the new ones.

One simple solution is to NOT have an event listener for the actual buttons, but instead tie it to document, then just look for the appropriate class on the button.

This answer is very rudimentary, its just to demonstrate the concept. If you notice the buttons are added to the DOM AFTER the event listener, but it still works.

document.addEventListener("click",function(e){
   let btn = e.target;
   if(btn.className.includes("increase")){
     console.log("increase")
   }
   else if(btn.className.includes("decrease")){
     console.log("decrease")
   }
});
let dest = document.querySelector("#dest");
dest.innerHTML = '<button class="increase">Increase</button><button class="decrease">Decrease</button>';
<div id="dest"></div>

&#x27;从购物车中删除项目&#x27;和管理数量&#x27;当我添加更多产品时,按钮不起作用

眼泪都笑了 2025-02-20 10:15:10

在.NET Core 6中创建的Azure Marketplace中有一个AS2客户端。它称为“ Integration Microservice AS2”,如果Azure不适合您,它们还可以为您的前提项目提供自定义解决方案。

there is an AS2 Client available in Azure Marketplace that is created in .NET Core 6. It is called "Integration Microservice AS2", they can also provide a custom solution for your on premise project if Azure is not working for you.

AS2服务器 - 使用(现代)C#.NET接收AS2消息

眼泪都笑了 2025-02-20 07:46:05

这是因为workspace尚未定义。您可以添加一个新变量来存储您保存的最新DIV。然后检查它是否不是零(第一次单击链接时为null。
然后,您可以将使用将最后一个div用作第二个参数

<div id="workspace">
    <script type="text/javascript">
        var my_div = document.getElementById("workspace");
        var newDiv = null;
        var lastDiv = null
        function addElement() {

            newDiv = document.createElement("div");
            newDiv.innerHTML = "<h7>Hi there and greetings!</h7>";
            newDiv.style.width = "200px";
            newDiv.style.height = "50px";
            newDiv.style.background = "red";
            my_div.appendChild(newDiv);
            if (lastDiv) {
                my_div.insertBefore(newDiv, lastDiv);
            }
            lastDiv = newDiv

        }
    </script>


    <a href="#" onclick="addElement()">ADD new greeting</a>
</div>

This is because workspace is not defined. You can add a new variable to store the latest div that you saved. Then check if it's not null (it's null when you click on the link for the first time.
Then you can use insertBefore with the last div as the second argument

<div id="workspace">
    <script type="text/javascript">
        var my_div = document.getElementById("workspace");
        var newDiv = null;
        var lastDiv = null
        function addElement() {

            newDiv = document.createElement("div");
            newDiv.innerHTML = "<h7>Hi there and greetings!</h7>";
            newDiv.style.width = "200px";
            newDiv.style.height = "50px";
            newDiv.style.background = "red";
            my_div.appendChild(newDiv);
            if (lastDiv) {
                my_div.insertBefore(newDiv, lastDiv);
            }
            lastDiv = newDiv

        }
    </script>


    <a href="#" onclick="addElement()">ADD new greeting</a>
</div>

无法执行插入&#x27; on Node&#x27;

眼泪都笑了 2025-02-20 07:22:05

您可以使用dict来保存重复每个file_name的计数,并在dict> dict中使用保存计数进行重命名。

import os
import re

pattern = "a1" 
path = "Files/" 

dct = {}                                                      # <- adding this
for root, dirs, files in os.walk(path):
    for file in files: 
            if pattern in file:
                file_new = file.split(pattern, 1)[1]
                if not file_new in dct:                        # <- adding this
                    os.rename(os.path.join(root, file), 
                              os.path.join(root,file_new[1:]))
                    dct[file_new] = 1                          # <- adding this
                else:
                    num = dct[file_new]                        # <- adding this
                    dct[file_new] += 1                         # <- adding this
                    file_name, file_type = file_new[1:].split('.')
                    os.rename(os.path.join(root, file), 
                              os.path.join(root, f'{file_name}_{num}.{file_type}'))

重命名之前的文件名:

“在此处输入图像描述”

重命名后的文件名:

You can use Dict for saving the count of repeating each file_name and use saving count in Dict for renaming.

import os
import re

pattern = "a1" 
path = "Files/" 

dct = {}                                                      # <- adding this
for root, dirs, files in os.walk(path):
    for file in files: 
            if pattern in file:
                file_new = file.split(pattern, 1)[1]
                if not file_new in dct:                        # <- adding this
                    os.rename(os.path.join(root, file), 
                              os.path.join(root,file_new[1:]))
                    dct[file_new] = 1                          # <- adding this
                else:
                    num = dct[file_new]                        # <- adding this
                    dct[file_new] += 1                         # <- adding this
                    file_name, file_type = file_new[1:].split('.')
                    os.rename(os.path.join(root, file), 
                              os.path.join(root, f'{file_name}_{num}.{file_type}'))

Filename before renaming:

enter image description here

Filename after renaming:

enter image description here

通过删除给定前缀模式来重命名文件名

眼泪都笑了 2025-02-19 13:55:00

您可以做这样的事情:

<StackPanel>
    <PasswordBox MaxLength="{Binding ElementName=ToggleButton, Path=IsChecked, Converter={StaticResource ToggleButtonToMaxLengthConverterKey}}"/>
    <ToggleButton x:Name="ToggleButton" Content="Set Length"/>
</StackPanel>

并使用转换器:

public class ToggleButtonToMaxLengthConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is bool isChecked)
        {
            return isChecked ? 5 : 12;
        }

        return 12;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

You can do something like this:

<StackPanel>
    <PasswordBox MaxLength="{Binding ElementName=ToggleButton, Path=IsChecked, Converter={StaticResource ToggleButtonToMaxLengthConverterKey}}"/>
    <ToggleButton x:Name="ToggleButton" Content="Set Length"/>
</StackPanel>

And use Converter:

public class ToggleButtonToMaxLengthConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is bool isChecked)
        {
            return isChecked ? 5 : 12;
        }

        return 12;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

我如何更改密码框的最高长度

眼泪都笑了 2025-02-19 09:13:12

让我们说,我们必须根据特定属性按升序顺序排列对象列表,在此示例中,我们必须根据“名称”属性进行排序,然后以下是所需的代码:

var list_Objects = [{"name"="Bob"},{"name"="Jay"},{"name"="Abhi"}];
Console.log(list_Objects);   //[{"name"="Bob"},{"name"="Jay"},{"name"="Abhi"}]
    list_Objects.sort(function(a,b){
        return a["name"].localeCompare(b["name"]); 
    });
Console.log(list_Objects);  //[{"name"="Abhi"},{"name"="Bob"},{"name"="Jay"}]

Let us say we have to sort a list of objects in ascending order based on a particular property, in this example lets say we have to sort based on the "name" property, then below is the required code :

var list_Objects = [{"name"="Bob"},{"name"="Jay"},{"name"="Abhi"}];
Console.log(list_Objects);   //[{"name"="Bob"},{"name"="Jay"},{"name"="Abhi"}]
    list_Objects.sort(function(a,b){
        return a["name"].localeCompare(b["name"]); 
    });
Console.log(list_Objects);  //[{"name"="Abhi"},{"name"="Bob"},{"name"="Jay"}]

按属性值对对象进行排序

眼泪都笑了 2025-02-18 18:52:50

我为您添加了您的错误消息。它说:

/opencv/modules/highgui/src/precomp.hpp:155:错误:( - 215:断言失败)src_depth!= cv_16f&amp;&amp;&amp;&amp; src_depth!= cv_32s在函数'converttoshow'中的cv_32s

imshow 不接受32位签名的整数(也不接受半浮子)。

除此之外,您需要给它任何东西。将您的数据转换为当前受支持的类型之一:uint8uint16floatdouble

介意价值范围。对于公认的整数,这是整个范围。对于浮子,它为0.0至1.0,映射到黑色/白色。如果您的值不使用使用预期的范围,则您可能会看到一个完全黑色的图像(未渗透)或主要是白色(过度暴露)的图像。

I added your error message for you. It says:

/opencv/modules/highgui/src/precomp.hpp:155: error: (-215:Assertion failed) src_depth != CV_16F && src_depth != CV_32S in function 'convertToShow'

That means imshow does not accept 32 bit signed integers (nor does it accept half floats).

You need to give it anything but that. Convert your data to one of the supported types, which are currently: uint8, uint16, float, double.

Mind the value range. For the accepted integers, it's the entire range. For floats, it's 0.0 to 1.0, that are mapped to black/white. If your values don't use the expected range, you might see an entirely black image (underexposed) or one that is mostly white (overexposed).

opencv imshow因src_depth!= cv_16f&amp;&amp; src_depth!= cv_32s在函数中&#x27; converttoshow&#x27;

眼泪都笑了 2025-02-18 04:41:13

有趣的是,http日志级别从源中的标准日志级别缺少:

https://github.com/winstonjs/winstonjs/winston/blob/master/lib/winston.js#l87

// Pass through the target methods onto `winston.
Object.keys(exports.config.npm.levels)
  .concat([
    'log',
    'query',
    'stream',
    'add',
    'remove',
    'clear',
    'profile',
    'startTimer',
    'handleExceptions',
    'unhandleExceptions',
    'handleRejections',
    'unhandleRejections',
    'configure',
    'child'
  ])
  .forEach(
    method => (exports[method] = (...args) => defaultLogger[method](...args))
  );

代码>:

https://wwwww.npmjs.com/package/package/package/logform

这样我就会结束http不是有效的Winston日志级别,这可能应该作为Winston Github上的问题提出。

Interestingly the http log level is missing from the standard log levels in the source:

https://github.com/winstonjs/winston/blob/master/lib/winston.js#L87

// Pass through the target methods onto `winston.
Object.keys(exports.config.npm.levels)
  .concat([
    'log',
    'query',
    'stream',
    'add',
    'remove',
    'clear',
    'profile',
    'startTimer',
    'handleExceptions',
    'unhandleExceptions',
    'handleRejections',
    'unhandleRejections',
    'configure',
    'child'
  ])
  .forEach(
    method => (exports[method] = (...args) => defaultLogger[method](...args))
  );

And seems to be coming from the package logform:

https://www.npmjs.com/package/logform

So I would conclude that http isn't a valid winston log level, this should probably be raised as an issue on the winston github.

温斯顿http日志级别的行为与信息不同

眼泪都笑了 2025-02-16 05:07:32

您应该为字符串设置格式(持续的长度且左填充零):

fprintf(fp, "%015d\n", (rand() % size*5) + 1)

然后在qsort函数中使用相同的长度+1在size参数时使用。

您还应将‍‍ cmp函数如下更改,以便将字符串转换为atoi的数字:

int cmp(const void *p1, const void *p2)
{
    const int i1 = atoi((char*)p1);
    const int i2 = atoi((char*)p2);
    return (i1 - i2);
}

我的建议代码是:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <time.h>
#include <stdlib.h>

#include <stdlib.h>
#include <unistd.h>

int cmp(const void *p1, const void *p2)
{
    const int i1 = atoi((char*)p1);
    const int i2 = atoi((char*)p2);
    return (i1 - i2);
}
//Function to create a txt with random integers in given size
void rand_txt(int size)
{
    srand(time(0));
    FILE *fp = fopen("rand.txt", "w");
    for (int i = 0; i < size; i++)
        fprintf(fp, "%015d\n", (rand() % size*5) + 1);
    fclose(fp);
}

int main()
{
    int COUNT=20;
    rand_txt(COUNT);
    int myFile = open("rand.txt", O_RDWR);
    struct stat myStat = {};
    fstat(myFile, &myStat);
    off_t size = myStat.st_size;

    char *addr =(char*) mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, myFile, 0);
    close(myFile);
    for (int i = 0; i < size; i++)
        printf("%c", addr[i]);

    qsort(addr, COUNT, 16, cmp);
    printf("\n-------------\n");
    for (int i = 0; i < size; i++)
        printf("%c", addr[i]);
    munmap(NULL, size);
    return 0;
}

You should set format for your strings(with constant length and zero left padding):

fprintf(fp, "%015d\n", (rand() % size*5) + 1)

and then use same length+1 at size argument in qsort function.

You should also change the ‍‍cmp function as follows so that it converts the string into a number by atoi:

int cmp(const void *p1, const void *p2)
{
    const int i1 = atoi((char*)p1);
    const int i2 = atoi((char*)p2);
    return (i1 - i2);
}

My suggested code is:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <time.h>
#include <stdlib.h>

#include <stdlib.h>
#include <unistd.h>

int cmp(const void *p1, const void *p2)
{
    const int i1 = atoi((char*)p1);
    const int i2 = atoi((char*)p2);
    return (i1 - i2);
}
//Function to create a txt with random integers in given size
void rand_txt(int size)
{
    srand(time(0));
    FILE *fp = fopen("rand.txt", "w");
    for (int i = 0; i < size; i++)
        fprintf(fp, "%015d\n", (rand() % size*5) + 1);
    fclose(fp);
}

int main()
{
    int COUNT=20;
    rand_txt(COUNT);
    int myFile = open("rand.txt", O_RDWR);
    struct stat myStat = {};
    fstat(myFile, &myStat);
    off_t size = myStat.st_size;

    char *addr =(char*) mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, myFile, 0);
    close(myFile);
    for (int i = 0; i < size; i++)
        printf("%c", addr[i]);

    qsort(addr, COUNT, 16, cmp);
    printf("\n-------------\n");
    for (int i = 0; i < size; i++)
        printf("%c", addr[i]);
    munmap(NULL, size);
    return 0;
}

在C中使用随机整数对MMMAPAPE进行排序

眼泪都笑了 2025-02-15 12:50:21

如评论中所述,这是浮点数学的性质。

就您而言,您可以在F弦中使用指定符来控制您的打印内容:

>>> n = 3.999996
>>> print(f"{n : .0f}")
 4
>>> 

As noted in comments, this is the nature of floating point math.

In your case, you can control what you print with a specifier in an f-string:

>>> n = 3.999996
>>> print(f"{n : .0f}")
 4
>>> 

为什么会发生?

眼泪都笑了 2025-02-15 08:47:58

问题不在POM中。您没有在管道配置中告诉执行哪个Maven目标。例如软件包或部署。错误显然是说明了这一点。

说,如果目标设定为空白,则构建将失败。

The problem is not in the pom. You are not telling in the pipeline configuration which of the Maven goals to execute. For example package or deploy. The error is clearly stating that.

Azure Maven task documentation says the build will fail if goals is set to blank.

无法创建Azure管道,它被卡在Maven阶段

眼泪都笑了 2025-02-15 07:24:29

要创建一个关系并将新列添加到Aspnetusers实体中,您必须定义和额外的类,这些类必须从IdentityUser继承。 示例

public class AspNetUserLogins

{

[Key]
public Guid Id {get; set;}

public Guid UserId {get; set;}

public virtual ApplicationUser User { get; set; }

}
    public class ApplicationUser : IdentityUser<Guid>
        {
            public ApplicationUser()
            {
                aspNetUserLogins = new List<AspNetUserLogins>();
    
            }
            public bool IsActive { get; set; }
            public bool IsDeleted { get; set; } = false;
            public virtual ICollection<AspNetUserLogins> aspNetUserLogins { get; set; }
        }

这是您必须设置的上下文类中的

 public class YourDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
    {
        public YourDbContext(DbContextOptions<YourDbContext> options)
            : base(options)
        {
        }
}

。我认为这是修改身份表的好方法。

For creating a relation and adding new columns to AspNetUsers entity you have to define and extra class which must be inherited from IdentityUser. Here is the example

public class AspNetUserLogins

{

[Key]
public Guid Id {get; set;}

public Guid UserId {get; set;}

public virtual ApplicationUser User { get; set; }

}
    public class ApplicationUser : IdentityUser<Guid>
        {
            public ApplicationUser()
            {
                aspNetUserLogins = new List<AspNetUserLogins>();
    
            }
            public bool IsActive { get; set; }
            public bool IsDeleted { get; set; } = false;
            public virtual ICollection<AspNetUserLogins> aspNetUserLogins { get; set; }
        }

On the context class you must set like this.

 public class YourDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
    {
        public YourDbContext(DbContextOptions<YourDbContext> options)
            : base(options)
        {
        }
}

This is I think good approach to modify Identity table.

ASP.NET核心MVC错误 - 实体类型&#x27; aspnetuserlogin&#x27;需要定义的主键

眼泪都笑了 2025-02-14 18:25:33

如果正确执行 span 元素将允许您在另一个元素中设计特定文本。 span span 与AP或H标签不同,将用作内联容器,该容器是块级别的,会导致您的句子​​断开。在下面运行代码片段,以查看一旦添加了几个类和CSS来更改一个句子中某些单词的样式,它的功能有多强大。希望您可以回收此示例以解决您的问题。

div {
  max-width: 450px;
  margin: 0 auto;
  padding: 2rem;
}

.text-drop-cap {
  font-size: 50px;
  font-family: "Playfair Display";
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  margin-right: 5px;
  color: #a3b2a4;
}

.text-bold {
  font-weight: 900;
}

.text-uppercase {
  text-transform: uppercase;
}
<div>
  <p><span class="text-drop-cap">L</span>orem ipsum dolor sit amet, <span class="text-uppercase">consectetur</span> adipiscing elit, sed do eiusmod <span class="text-bold">tempor incididunt</span> ut labore et dolore magna aliqua.</p>
</div>

If executed correctly the span element will allow you to style specific text within another element. The span element is used as an inline container unlike a p or H tag that are block level and will cause your sentence to break. Run the code snippet below to see how powerful it is once you add a few classes and CSS to change the style of certain words within one sentence. Hope you can recycle this example to solve your problem.

div {
  max-width: 450px;
  margin: 0 auto;
  padding: 2rem;
}

.text-drop-cap {
  font-size: 50px;
  font-family: "Playfair Display";
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  margin-right: 5px;
  color: #a3b2a4;
}

.text-bold {
  font-weight: 900;
}

.text-uppercase {
  text-transform: uppercase;
}
<div>
  <p><span class="text-drop-cap">L</span>orem ipsum dolor sit amet, <span class="text-uppercase">consectetur</span> adipiscing elit, sed do eiusmod <span class="text-bold">tempor incididunt</span> ut labore et dolore magna aliqua.</p>
</div>

使用CSS在段落中编辑特定句子

眼泪都笑了 2025-02-14 08:11:51

似乎与IIS应用程序池标识权限问题有关。我建议您首先可以将其设置为系统,以查看是否可以解决此问题。

如下图:

“在此处输入图像描述”

如果这已经解决了您的问题,则可以运行 process Monitor 要查看访问临时文件夹的许可,在检查临时文件夹之后,您可以修改默认身份提供商IIS AppPool \ DefaultAppPool的权限以解决此问题

It seems is related with the IIS application pool identity permission issue. I suggest you could firstly set it as system to see if it could resolve this issue.

Like below:

enter image description here

If this has solved your issue, then you could run process monitor to see which permission is needed for accessing the temp folder, after checking it, you could modify the default identity provider IIS APPPOOL\DefaultAppPool's permission to solve this issue

带有ASP.NET Core 5的Rotativa

眼泪都笑了 2025-02-13 18:52:08

不,目前不可能(从Firefox 101开始)在调试时跳过线路。

您可能要做的就是在调试时操纵代码。例如,当变量在断点停止时分配新值时,您可以重置该变量的值。或者,当下一个语句是函数调用时,您可以用一个空功能替换该函数。
当然,并非总是有可能将声明变成一个no-op。这样做可能会产生副作用。

No, it's currently not possible (as of Firefox 101) to skip lines when debugging.

What you may do is manipulate the code while you're debugging. E.g. you can reset the value of a variable when it gets a new value assigned while the execution is stopped at a breakpoint. Or when the next statement is a function call, you can replace that function by an empty one.
Of course, it is not always possible to turn a statement into a no-op. And doing so may have side effects.

在Firefox中调试JavaScript时,是否可以跳过一系列代码?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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