小编use*_*018的帖子

"EventTarget"类型中不存在属性"值"

我使用TypeScript版本2作为Angular 2组件代码.

我收到错误"属性'值'在类型'EventTarget'上不存在"下面的代码,可能是解决方案.谢谢!

e.target.value.match(/\S +/g)|| []).长度

import { Component, EventEmitter, Output } from '@angular/core';

@Component({
selector: 'text-editor',
template: `
<textarea (keyup)="emitWordCount($event)"></textarea>
 `
 })
  export class TextEditorComponent {
   @Output() countUpdate = new EventEmitter<number>();

emitWordCount(e: Event) {
    this.countUpdate.emit(
        (e.target.value.match(/\S+/g) || []).length);
}
}
Run Code Online (Sandbox Code Playgroud)

typescript angular

69
推荐指数
11
解决办法
4万
查看次数

类型"{}"不能分配给类型'{title:string; text:string; }"

我收到以下TypeScript代码的错误,

类型'{}'不能分配给'{title:string; text:string; }"."{}"类型中缺少属性"标题".

因为我在下面声明"文章",

article: { title: string, text: string } = {};
Run Code Online (Sandbox Code Playgroud)

它是什么原因以及如何解决这个问题?谢谢!

import { Component } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';

@Component({
    selector: 'article-editor',
    template: `
    <p>Title: <input [formControl]="titleControl"></p>
    <p>Text: <input [formControl]="textControl"></p>
    <p><button (click)="saveArticle()">Save</button></p>
    <hr />
    <p>Preview:</p>
    <div style="border:1px solid #999;margin:50px;">
      <h1>{{article.title}}</h1>
      <p>{{article.text}}</p>
    </div>
  `
})
export class ArticleEditorComponent {
    article: { title: string, text: string } = {};

    titleControl: FormControl = new FormControl(null, Validators.required);
    textControl: FormControl = new FormControl(null, Validators.required);
    articleFormGroup: …
Run Code Online (Sandbox Code Playgroud)

typescript angular

14
推荐指数
2
解决办法
2万
查看次数

如何从 jwt 令牌获取“exp”并与当前时间进行比较以检查令牌是否过期

我正在使用System.IdentityModel.Tokens.Jwt包和下面的代码解码令牌jwt,但它不会给出 exp值?

 var handler = new JwtSecurityTokenHandler();
 var decodedValue = handler.ReadJwtToken("token");
Run Code Online (Sandbox Code Playgroud)

如何获取exp并与当前DateTime进行比较来计算token是否过期?

在此输入图像描述

更新:

我正在使用Azure.Core.AccessToken我拥有以下属性的地方,

public DateTimeOffset ExpiresOn
    {
        get;
    }
Run Code Online (Sandbox Code Playgroud)

c# jwt azure-active-directory bearer-token

13
推荐指数
2
解决办法
3万
查看次数

如何创建一个HTML Helper来扩展TextBoxFor()以添加CSS样式?

如何创建一个HTML Helper来扩展TextBoxFor()以添加CSS样式?

@Html.TextBoxFor(model => model.FirstName, new { @class = "txt" }) 
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc asp.net-mvc-3

8
推荐指数
2
解决办法
1万
查看次数

如何检测隐藏输入字段的值更改

我有一个textarea在我正在实现的MVC应用程序中AspNetSpellCheck,调试器告诉我textareadisplay: none; visibility: hidden;和a 的更改div是用id="abc"和生成的class"="pqr".

<input type="hidden" value="" name="userid" id="useid" />
Run Code Online (Sandbox Code Playgroud)

此外,我正在为所有文本区域/其他控件实现更改检测....

var somethingChanged = false;
$(document).ready(function() { 
    $('input').change(function() { 
       somethingChanged = true; 
    }); 
});
Run Code Online (Sandbox Code Playgroud)

因为文本区域变得隐藏,我想它不会自动触发change()事件.在上述案例中解雇事件的解决方案是什么?谢谢!

编辑

使用AspNetSpellCheck,下面是我的代码,

  @{  

  ASPNetSpell.Razor.SpellAsYouType mySpell = new ASPNetSpell.Razor.SpellAsYouType();
   mySpell.InstallationPath = ("/Content/ASPNetSpellInclude");
   mySpell.FieldsToSpellCheck = "TextArea1";
}

<textarea id="TextArea1" cols="20" rows="2">bedddly</textarea>
@Html.Raw(mySpell.getHtml())

<script type="text/javascript" language="javascript">

$(document).ready(function () {
    $('input[type="hidden"]').change(function () {
        debugger;
        alert('hi');
        // somethingChanged = true; 
    });
});


 </script> …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc jquery

8
推荐指数
2
解决办法
2万
查看次数

启动失败,因为容器中的目录“/remote_debugger”为空

我有一个dotnet core 3.1Web api 应用程序,我正在使用 Visual Studio 2019dockerdocker-compose工具功能来运行该应用程序。

当我尝试运行该应用程序时,出现以下错误,

启动失败,因为容器中的目录“/remote_debugger”为空。这可能是由于 Docker Desktop 使用的共享驱动器凭据已过期所致。尝试在 Docker 桌面设置的共享驱动器页面中重置凭据,然后重新启动 Docker

在此输入图像描述

构建成功,以下是输出。我看到一些与PS脚本相关的错误。是这个原因吗?

我需要重新设置什么凭据,有人可以建议吗?

C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy RemoteSigned -文件“C:\Users\user1\AppData\Local\Temp\GetVsDbg.ps1” -版本 vs2017u5 - RuntimeID linux-x64 -InstallPath“C:\Users\user1\vsdbg\vs2017u5”AuthorizationManager 检查失败。+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + ExcellentQualifiedErrorId : UnauthorizedAccess C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy RemoteSigned -文件“C:\Users\ user1\AppData\Local\Temp\GetVsDbg.ps1" -Version vs2017u5 -RuntimeID linux-musl-x64 -InstallPath "C:\Users\user1\vsdbg\vs2017u5\linux-musl-x64" AuthorizationManager 检查失败。+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + ExcellentQualifiedErrorId : UnauthorizedAccess 准备容器时发生非严重错误。您的项目将继续正常运行。错误是:Dockerfile 'C:\Users\user1\source\repos\WebApplication1\WebApplication1\Dockerfile' …

visual-studio docker docker-compose asp.net-core-3.1

8
推荐指数
1
解决办法
1363
查看次数

从可排序项中排除项目

我有以下示例表代码,

<table id="Table1">
<thead>
    <th>Title</th>
</thead>
<tbody>
    <tr>
        <td>Row 1</td>
    </tr>
    <tr>
        <td>Row 2</td>
    </tr>
    <tr>
        <td>Row 3</td>
    </tr>
    <tr class='disabled'>
        <td>Row 4</td>
    </tr>
    <tr>
        <td>Row 5</td>
    </tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我在jQuery Sortable下面申请,工作正常,

$("#Table1 tbody").sortable({
});
Run Code Online (Sandbox Code Playgroud)

但是,现在我想排除类别为"禁用"的"tr"排序,我要应用下面的代码(jquery选择器),但它不起作用.选择器有什么问题吗?我必须在HTML表格中使用"thead"和"tbody".

或者有其他方法吗?谢谢,

$("#Table1 tbody tr:not(.disabled)").sortable({
});
Run Code Online (Sandbox Code Playgroud)

jquery jquery-selectors jquery-ui-sortable

7
推荐指数
1
解决办法
3934
查看次数

如何使用与singleton类的接口

当我解决Singleton Vs Static类之间的差异时,我遇到了一个问题,即我们可以在singleton类中继承一个接口,并且可以通过接口调用singleton来实现多个实现.

我希望通过一个很好的例子进行一些代码演示,如何通过单例而不是静态来实现面向对象.

谢谢,

c#

7
推荐指数
1
解决办法
2万
查看次数

添加到C#字典:无法从'string'转换为'System.Collections.Specialized.NameValueCollection'

我有一个数据源,其中包含3个不同的值,如下所示,

List<Configuration> lst = new List<Configuration>
        {
            new Configuration{Name="A", Config="X", Value="1"},
            new Configuration{Name="A", Config="X", Value="2"},
            new Configuration{Name="B", Config="Y", Value="2"}
        };

 public class Configuration
{
    public string Name { get; set; }
    public string Config { get; set; }
    public string Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

在这里,我想迭代到整个源,并希望将"Name"值保持为KEY,将"Config"和"Value"保存为"NameValueCollection".

为此,我正在拿一本如下的字典,

var config = new Dictionary<string, NameValueCollection>();
Run Code Online (Sandbox Code Playgroud)

但是在添加到这本词典时,我遇到了2个问题,

foreach(var c in lst)
        {
            config.Add(c.Name, new NameValueCollection { c.Config, c.Value });
        }
Run Code Online (Sandbox Code Playgroud)
  1. 重复键(名称="A")
  2. 这一行给出错误,新的NameValueCollection {c.Config,c.Value});

注意 - 我希望X和1都是1(如果是重复键)

有没有更好的C#集合或如何解决上述错误.

谢谢!

c#

7
推荐指数
2
解决办法
981
查看次数

将包从“Microsoft.Extensions.Configuration.AzureKeyVault”更改为“Azure.Extensions.AspNetCore.Configuration.Secrets”

我正在使用 nuget Microsoft.Extensions.Configuration.AzureKeyVault,并且在 中使用下面的 asp.net core 3.1 代码Program.cs

我正在为 azure keyVault 进行自定义证书身份验证。还使用自定义秘密管理。

   public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((context, config) =>
            {
                    config.AddAzureKeyVault(new AzureKeyVaultConfigurationOptions
                    {
                        Vault = "key vault url",
                        ReloadInterval = TimeSpan.FromSeconds(15),
                        //authenticate with custom certificate
                        Client = new KeyVaultClient(CustomCertificateAuthenticationCallback),
                        Manager = new CustomKeyVaultSecretManager()
                    });
                }
            })
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            }); 
Run Code Online (Sandbox Code Playgroud)

该软件包Microsoft.Extensions.Configuration.AzureKeyVault已被弃用,我已卸载该软件包并安装了更新的软件包Azure.Extensions.AspNetCore.Configuration.Secrets。切换到这个包后,我无法弄清楚如何使用custom验证以及如何通过keyvault url

azure-keyvault asp.net-core-3.1

7
推荐指数
1
解决办法
5504
查看次数