我正在尝试向表单添加转换,以便当用户选择问题的特定答案时,它将动态显示下一个问题。目前我的它看起来像这样:
<input type="text" :value="vueModel.question1" />
<div v-if="vueModel.question1 === 'hello'">
//Do something
</div>
<div v-else-if="vueModel.question1 === 'hihi'">
//Do something
</div>
<div v-else>
//Do something
</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是,我应该以这种方式添加过渡吗?(为什么?)
<input type="text" :value="vueModel.question1" />
<transition-group name="slide-fade" mode="in-out">
<div v-if="vueModel.question1 === 'hello'" key="key1">
//Do something
</div>
<div v-else-if="vueModel.question1 === 'hihi'" key="key2">
//Do something
</div>
<div v-else key="key3">
//Do something
</div>
</transition-group>
Run Code Online (Sandbox Code Playgroud)
或者,这样?(为什么?)
<input type="text" :value="vueModel.question1" />
<transition name="slide-fade" mode="in-out">
<div v-if="vueModel.question1 === 'hello'" key="key1">
//Do something
</div>
<div v-else-if="vueModel.question1 === 'hihi'" key="key2">
//Do something
</div>
<div …Run Code Online (Sandbox Code Playgroud) 如果流畅的验证方法失败,我想运行一个方法。
RuleFor(x => x.SheepName)
.Must(x => x.SheepName == null)
.When(x => x.HasSheep == false)
.Otherwise(callMethod());
Run Code Online (Sandbox Code Playgroud)
因此,在这种情况下,如果 HasSheep 值为 false 但仍然给出了 SheepName,那么我想运行一个方法(在示例中该方法称为“callMethod()”)。
我已经编写了 .Otherwise 语句,因此寻找整行 '.Otherwise(callMethod());' 的内容 需要是..
我正在尝试在服务器上安装 Windows 服务,当以管理员身份运行命令行并导航到 InstalUtil.cmd 文件并运行它时,我收到错误“msiexec failed: 1603”,但是该服务确实已安装并且按预期完美运行。有任何想法/建议来修复错误消息吗?
我有 ac# 模型类 (Address.cs),看起来像这样......
namespace myProject.Models
{
[Validator(typeof(AddressValidator))]
public class Address
{
public string AddressLine1 { get; set; }
public string PostCode { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个验证器类(AddressValidator.cs),看起来像这样......
namespace myProject.Validation
{
public class AddressValidator : AbstractValidator<Address>
{
public AddressValidator()
{
RuleFor(x => x.PostCode).NotEmpty().WithMessage("The Postcode is required");
RuleFor(x => x.AddressLine1).MaximumLength(40).WithMessage("The first line of the address must be {MaxLength} characters or less");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何为我的验证器类添加单元测试,以便我可以测试“地址行 1”最多占用 40 个字符?
我能够让axios在浏览器上下载pdf文件,并且pdf中每页的页数/页面方向是正确的,但内容是空的。
这是我的 API:
[HttpGet]
[Route("~/api/Document")]
public HttpResponseMessage Get(int id)
{
var dataBytes = File.ReadAllBytes("c:\\temp\\test.pdf");
var stream = new MemoryStream(dataBytes);
HttpResponseMessage httpResponse = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
httpResponse.Content = new StreamContent(stream);
httpResponse.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
httpResponse.Content.Headers.ContentDisposition.FileName = "test";
httpResponse.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
return httpResponse;
}
Run Code Online (Sandbox Code Playgroud)
然后我的 vue js axios 调用:
test: function () {
var self = this;
var uri = '/api/Document';
axios.get(uri)
.then(function (response) {
console.log(response);
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'test.pdf'); //or any …Run Code Online (Sandbox Code Playgroud) c# ×3
vue.js ×2
api ×1
axios ×1
command-line ×1
download ×1
html ×1
javascript ×1
transition ×1
unit-testing ×1
validation ×1
windows ×1