小编CRo*_*rts的帖子

何时使用过渡与过渡组

我正在尝试向表单添加转换,以便当用户选择问题的特定答案时,它将动态显示下一个问题。目前我的它看起来像这样:

<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)

html javascript transition vue.js

6
推荐指数
1
解决办法
3709
查看次数

流畅验证失败后如何调用方法

如果流畅的验证方法失败,我想运行一个方法。

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());' 的内容 需要是..

c# validation fluentvalidation

4
推荐指数
1
解决办法
948
查看次数

MSI 安装程序错误 - MSIExec 失败:1603

我正在尝试在服务器上安装 Windows 服务,当以管理员身份运行命令行并导航到 InstalUtil.cmd 文件并运行它时,我收到错误“msiexec failed: 1603”,但是该服务确实已安装并且按预期完美运行。有任何想法/建议来修复错误消息吗?

windows command-line windows-installer windows-services

3
推荐指数
1
解决办法
2万
查看次数

如何将单元测试添加到我的流畅验证类中?

我有 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 个字符?

c# unit-testing fluentvalidation

2
推荐指数
1
解决办法
7948
查看次数

VueJs/Axios - 如何通过 API 调用在浏览器中下载 pdf 文件

我能够让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# api download vue.js axios

2
推荐指数
1
解决办法
5186
查看次数