我有一个简单的JQuery移动应用程序的问题.这一切都归结为点击事件两次触发.
没有类似问题的解决方案解决了这个问题.
无论是部署到设备还是在浏览器中显示,都会出现问题.
这是代码
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<script src="jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="jquery.mobile-1.2.0.min.js" type="text/javascript"></script>
<script src="cordova-2.2.0.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function () {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
});
</script>
<link rel="Stylesheet" href="jquery.mobile-1.2.0.min.css" />
Run Code Online (Sandbox Code Playgroud)
<div>
<input type="button" id="ButtonSubmit" value="Save" />
</div>
Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript">
$("#ButtonSubmit").click(function () {
alert('Clicked');
});
</script>
Run Code Online (Sandbox Code Playgroud)
如果将LINQ Take扩展方法应用于a SortedList<int, int>,如何将结果转换为新的SortedList<int, int>?
从我得到的运行时错误中,Take方法的结果是EnumerablePartition无法转换为SortedList<int, int>
控制台App中的主要方法编译正常,但是在将list.Take(2)转换为SortedList时在运行时抛出错误
static void Main(string[] args)
{
Console.WriteLine("List");
var list = new SortedList<int, int>();
list.Add(2, 10);
list.Add(8, 9);
list.Add(3, 15);
foreach (KeyValuePair<int, int> item in list){
Console.WriteLine(item.Value);
};
Console.WriteLine("Short List");
var shortlist = (SortedList<int, int>)list.Take(2);
foreach (KeyValuePair<int, int> item in shortlist)
{
Console.WriteLine(item.Value);
};
Console.Read();
}
Run Code Online (Sandbox Code Playgroud)
我本来希望该Take方法的结果是新的,SortedList<int, int>或者至少可以转换为SortedList<int, int>给定的原始类型。
这是我遇到的运行时错误:
Unable to cast object of type 'EnumerablePartition`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.Int32]]' to type 'System.Collections.Generic.SortedList`2[System.Int32,System.Int32]'
编辑: …
将 DateTimeOffset 转换为另一个 TimeZone 时,OffSet 不正确。
我读过很多文章并尝试了太多时间,但看不出我在这里缺少什么:
// It's June in the UK and we're in British Summer Time, which is 1 hour ahead of UTC (GMT)
var UKoffsetUtc = new TimeSpan(1, 0, 0);
// It's 4pm - declare local time as a DateTimeOffset
var UKdateTimeOffset = new DateTimeOffset(2020, 6, 17, 16, 0, 0, UKoffsetUtc);
// Convert to UTC as a date
var utc = DateTime.SpecifyKind(UKdateTimeOffset.UtcDateTime, DateTimeKind.Utc);
// Get Aus TimeZoneInfo
var AUSTimeZone = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
// Check …Run Code Online (Sandbox Code Playgroud) 如何使用按钮触发器上的模板参考变量以编程方式打开Angular Material菜单,可以使用ViewChild在组件中访问它?
该菜单通常在单击时打开,但是我想在鼠标悬停时以编程方式将其打开。
(鼠标悬停)事件处理程序给出错误:无法读取未定义的属性'openMenu'。
那么,为什么在组件中未定义clickHoverMenuTrigger?
这是组件html
<button mat-icon-button [matMenuTriggerFor]="clickHoverMenu"
#clickHoverMenuTrigger (mouseover)="openOnMouseOver()">
<mat-icon>notifications</mat-icon>
</button>
Run Code Online (Sandbox Code Playgroud)
这是组件打字稿
@ViewChild(MatMenuTrigger) clickHoverMenuTrigger: MatMenuTrigger;
openOnMouseOver() {
this.clickHoverMenuTrigger.openMenu();
}
Run Code Online (Sandbox Code Playgroud)
此方法记录在这里https://material.angular.io/components/menu/overview
在这里提出并回答了相同的问题,如何从打字稿访问垫菜单触发器(我没有对此发表评论的声誉)
看来我正在按照上面的文档和StackOverflow解决方案中所述进行操作。
由于clickHoverMenuTrigger未定义,因此@ViewChild必须是一个问题。
Stackblitz上的代码。打开控制台以查看错误。