这是我使用MVC2时遇到的错误:
Either ErrorMessageString or ErrorMessageResourceName must be set, but not both.
Run Code Online (Sandbox Code Playgroud)
它来自[Required] Validation DataAnnotation.
堆栈跟踪:
InvalidOperationException: Either ErrorMessageString or ErrorMessageResourceName must be set, but not both.]
System.ComponentModel.DataAnnotations.ValidationAttribute.SetupResourceAccessor() +89338
System.ComponentModel.DataAnnotations.ValidationAttribute.FormatErrorMessage(String name) +38
System.Web.Mvc.<Validate>d__1.MoveNext() +215
System.Web.Mvc.<Validate>d__5.MoveNext() +735
System.Web.Mvc.DefaultModelBinder.OnModelUpdated(ControllerContext controllerContext, ModelBindingContext bindingContext) +424
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +732
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +475
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +152
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +709
System.Web.Mvc.Controller.ExecuteCore() +162
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +58
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371
Run Code Online (Sandbox Code Playgroud)
我把我的视图模型煮到了这个(它会在任何时候出现[Required]属性,在没有的情况下工作正常):
[Required(ErrorMessage = "")]
[DataType(DataType.Text)]
[DisplayName("Property Name")] …Run Code Online (Sandbox Code Playgroud) 完整错误文字:
The type arguments for method 'System.Web.Mvc.Html.DisplayExtensions.DisplayFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Run Code Online (Sandbox Code Playgroud)
它刚刚开始发生,但我不相信我做了任何会影响此功能的更改.抛出VS intellisense错误,但页面功能正常.
不是"For"帮助程序的Html帮助程序工作得很好,它只是包含这些表达式的帮助程序.
违规标记(100个例子):
<%: Html.DisplayFor(model => model.PortfolioName) %>
Run Code Online (Sandbox Code Playgroud)
页面指令:
<%@ Page Language="C#" Inherits="ViewPage<My.Namespace.PortfolioViewModel>" %>
Run Code Online (Sandbox Code Playgroud)
查看型号:
namespace My.Namespace
{
public class PortfolioViewModel
{
[Required(ErrorMessage = " ")]
[DataType(DataType.Text)]
[DisplayName("Portfolio Name:* ")]
public string PortfolioName { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个函数,我首先检查作为参数传递的字符串是否只有字母.但它总是以虚假的方式回归.下面是我的jsfiddle
function takeString (str) {
var regex = "/^[A-Za-z]+$/";
if (str.match(regex)) {
if (str.charCodeAt(0) === str.toUpperCase().charCodeAt(0)) {
alert('true');
return true;
}
else {
alert('false');
return false;
}
}
else {
alert('Only letters please.');
}
}
takeString('string');
Run Code Online (Sandbox Code Playgroud)
以上代码始终提醒Only letters please.
我在 NextJs 中经常使用的一种模式是渲染服务器端的所有内容(包括数据获取),然后过渡到动态客户端渲染。人为的例子:
export async function getServerSideProps() {
const res = await fetch(`api/myData`)
const data = await res.json()
return {
props: { initialData: [data] }
}
}
export default function About({ initialData }) {
const [data, setData] = useState(initialData)
const addItem = () => {
const item = "foo"
const res = await fetch('/api/addData')
setData([...data, JSON.parse(res.body).item])
}
return (
<div>
{data.map(item => (<div>{item}</div>))}
<button onClick={addItem}>Add Item</button>
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何通过构建 NextJs 的新 App Router 风格获得相同类型的功能。谁能告诉我我缺少什么?
通过npm install -g nodeinspector安装了node-inspector.
我可以到达仪表板,但它在搜索栏外面只是空白.
我已经尝试在各种订单中启动app/inspector/browser并重新安装了node-inspector几次.有人建议我手动安装连接和异步模块,但没有用.
有帮助吗?

任何时候我在本地进行更改并执行任一操作git commit --amend,然后:x保存并关闭 vim 或者甚至只是git commit --amend --no-edit什么也没有发生。没有提交或上演任何本地更改。我完全困惑这怎么可能。其他rebaseing 活动与编辑器正常工作。
这是完整的工作重现:
\n\namendwtf|master \xe2\x87\x92 ls\nfile\namendwtf|master \xe2\x87\x92 git status\nOn branch master\nnothing to commit, working tree clean\namendwtf|master \xe2\x87\x92 echo \'a change appears\' > file\namendwtf|master\xe2\x9a\xa1 \xe2\x87\x92 git status\nOn branch master\nChanges not staged for commit:\n (use "git add <file>..." to update what will be committed)\n (use "git checkout -- <file>..." to discard changes in working directory)\n\n modified: file\n\nno changes added to commit (use "git add" and/or …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×2
.net ×1
asp.net ×1
git ×1
javascript ×1
jquery ×1
next.js ×1
node.js ×1
reactjs ×1
regex ×1