我正在将 Angular 10 应用程序升级到 Angular 13。我在依赖项的其他兼容性方面做得很好。该项目正在编译并且运行良好。现在是 TSLint 的时间了,我尝试使用以下命令更新 lint。
ng add @angular-eslint/schematics
Run Code Online (Sandbox Code Playgroud)
但收到错误消息:
An unhandled exception occurred: NOT SUPPORTED: keyword "id", use "$id" for schema ID
Run Code Online (Sandbox Code Playgroud) ng update
Run Code Online (Sandbox Code Playgroud)
无法从工作区根目录解析“@angular-devkit/schematics”包。这可能是由于不受支持的节点模块结构所致。请同时删除“node_modules”目录和包锁文件;然后重新安装。如果这不能解决问题,请在工作区中临时安装“@angular-devkit/schematics”包。更新完成后可以将其删除。
我Enum有个叫CityType
public enum CityType
{
[Description("Select City")]
Select = 0,
[Description("A")]
NewDelhi = 1,
[Description("B")]
Mumbai = 2,
[Description("C")]
Bangalore = 3,
[Description("D")]
Buxar = 4,
[Description("E")]
Jabalpur = 5
}
Run Code Online (Sandbox Code Playgroud)
从枚举生成列表
IList<SelectListItem> list = Enum.GetValues(typeof(CityType)).Cast<CityType>().Select(x => new SelectListItem(){
Text = EnumHelper.GetDescription(x),
Value = ((int)x).ToString()
}).ToList();
int city=0;
if (userModel.HomeCity != null) city= (int)userModel.HomeCity;
ViewData["HomeCity"] = new SelectList(list, "Value", "Text", city);
Run Code Online (Sandbox Code Playgroud)
绑定.cshtml
@Html.DropDownList("HomeCity",null,new { @style = "width:155px;", @class = "form-control" })
Run Code Online (Sandbox Code Playgroud)
EnumHelper GetDescription类获取Enum的描述
成功安装后,我尝试查找 Angular cli 的版本,但它显示弹出Window Script Host模型并出现错误。
我尝试使用后出现 Windows Script Host
ng version
Run Code Online (Sandbox Code Playgroud)