1.8k 2 分钟

做项目时,遇到个问题,现象是:需要 button 按钮点击请求后端返回数据,通过验证后再执行后续逻辑。 代码大致如下: s<form method="post"> <input type="text" id="LoginInput_UserNameOrEmailAddress" placeholder="请输入用户名或邮箱" aria-label="UserNameOrEmailAddress"/> <input...
307 1 分钟

# Any 是判断列表里面是否有满足条件的(至少一个) pbool res = masterList.Any(x=>x.name == "小明");# All 是判断列表里面是否每一项都包含 pbool res = masterList.All(x=>x.identity == "打工人");同时,Any () 方法常常可以用来检查列表是否为空。如果列表中有一个元素,则 List.Any () 函数将返回 true;否则返回 false。 pif(empytList.Any()){...
1.7k 2 分钟

s<script type="text/javascript">function doCheck() { var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; var v = document.getElementById("txt").value; if (!reg.test(v)) {...
1.6k 1 分钟

# 默认绑定 @bind 数据绑定的对象可以为字段、属性或表达式值 @bind 默认绑定的是元素的 onchange 事件,通过在组件中添加一个元素 p 可以看出效果,每当 input 离开 focus 或者回车时,p 中的值才会更新 r<input @bind="_bindValue1" /><p>@_bindValue1</p>@code{ private int _bindValue1 { get; set; } = 1;}由于...
228 1 分钟

用 git 提交代码到 github 的时候遇到了一个报错: Failed to connect to github.com port 443: Timed out 这个错误大致是说连接到 github 的时候超时了。那么该怎么解决呢?很简单,这个超时了无非就是你的代理出了点问题,不过好在 git 上用几个命令就能够很快搞定。 tgit config --global --unset http.proxy git config --global --unset https.proxy然后再 push,就可以了
705 1 分钟

ppublic enum EumPoliticSstatus { [Display(Name = "党员")] PartyMember = 1, [Display(Name = "团员")] Member = 2, [Display(Name = "群众")] Masses = 3, [Display(Name = "民主党派")] DemocraticParty = 4 }根据枚举值获取 DisplayName 首先我们需要定义一个静态类,为枚举添加一个扩展方法 ppublic...
912 1 分钟

此功效无法百分百通过 C# 代码来实现,需要与 JS 举行交互。 先编写 JS: swindow.clipboardCopy = { copyText: function (text) { navigator.clipboard.writeText(text).then(function () { alert("Copied to clipboard!"); }) .catch(function (error) { alert(error); });...
1.9k 2 分钟

防抖 - Debounce 连续的多次调用,只有在调用停止之后的一段时间内不再调用,然后才执行一次处理过程。 节流阀 - Throttle 连续的多次调用,在每个时间段的周期内只执行第一次处理过程。 代码如下: pusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Timers;using System.Threading.Tasks;using System.ComponentModel; namespace HZ.Common{...