我有一个日期选择器,用于选择特定日期。在此日期选择器中,我想将周数显示为单独的列-不一定显示为可选值,而只是查看您的日期位于哪一周。
<input type="week">
...不太合适,因为我需要能够选择一个特定的日期,而不仅仅是一周。实际上,我不需要选择星期数,只需要在日历中显示它即可。
关于此的任何提示吗?
答案 0 :(得分:0)
我尝试了这个解决方案,它对我很有用,如果您看到错误或有注释,请告诉我更正解决方案!
//Code behind
private string WeekVal {get; set;}
private Dictionary<string,object> dic {get; set;} = new
Dictionary<string,object> {{"type","week"}};
protected override void OnInitialized()
{
var year= DataTime.Now.Year;
var week= DataTime.Now.DayOfYear / 7;
WeekVal= $"{year}-W{week}";
}
//Blazor page
<inputText @attribute="dic" @bind-Value="WeekVal" />
Safari and Firefox don't support it on desktop, and old versions of IE don't support it.
read more