在使用amp-bind
模板中的amp-mustache
时,我似乎无法通过[value]属性动态设置表单输入字段的值。仅在Gmail客户端中会发生此问题。它可以在Gmail Amp Playground和浏览器中正常运行。此问题only在Gmail客户端中发生。它在Gmail Amp Playground(我认为应该反映Gmail客户端的行为)和浏览器中按预期工作。
要旨与客户代码的人为设计版本here。
非常感谢任何建议/解决方法!
虽然可能不需要,但这是服务器端逻辑:
public class TestRequestModel {
public string TestId { get; set; }
}
private string ValidId = "correct";
[HttpPost]
public async Task<IActionResult> TestGetId([FromForm]AEGetRepresentativesRequestModel requestModel)
{
AddRequiredAmpHeaders();
if (requestModel == null)
{
return BadRequest(new {});
}
return Ok(new TestRequestModel { TestId = ValidId });
}
[HttpPost]
public async Task<IActionResult> TestUseId([FromForm]TestRequestModel requestModel)
{
AddRequiredAmpHeaders();
if (requestModel == null)
{
return BadRequest(new {});
}
if (requestModel.TestId != ValidId)
{
return BadRequest(new { Error = $"Invaild id: {requestModel.TestId}" });
}
return Ok(new { TestId = ValidId });
}