【发布时间】:2021-04-26 01:50:35
【问题描述】:
我将 ASP NET 与 VueJS 一起使用。 ASP NET 渲染视图组件:
<script type="text/x-template" id="form-template">
@if (string.IsNullOrEmpty(Model.LastName))
{
<input asp-for="LastName" class="form-control" maxlength="100" autofocus required />
}
else
{
<input asp-for="LastName" class="form-control" maxlength="100" required />
}
</script>
我对 C# 的操作:
public async Task<ActionResult<ViewComponent>> GetAdditionalFormRegistrationComponentAsync()
{
var customerViewModel = new CustomerAdditionFormViewModel
{
LastName = "русские символы"
};
return ViewComponent("FormRegistration", customerViewModel);
}
}
视图组件:
public Task<IViewComponentResult> InvokeAsync(CustomerAdditionFormViewModel customerViewModel)
{
return Task.Run<IViewComponentResult>(() => View(customerViewModel));
}
LastName 写成英文输入值OK。但如果姓氏填写俄语,我会得到:
如何解决这个问题?
【问题讨论】:
-
为什么用 vue/javascript 标记?
-
@evolutionxbox 因为我在这个模板中使用了 vue。我认为我的问题使用 type="text/x-template"
-
能否更新问题,使代码成为可运行的minimal reproducible example?
-
@evolutionxbox 我更新了
-
@Viktor,您也可以使用
keyboard或monitor对其进行标记,因为您使用它们来查看您的网站。 Javascript 和/或 Vue 专家可以帮助您,就像键盘和显示器专家可以帮助您一样多。您的问题归结为您的后端如何为页面提供服务。最多可以用html标记它,因为它可能与html 编码有关。
标签: html asp.net vue.js keyboard monitor