小编Fra*_*eau的帖子

CdkDrag 更新位置

我有多个 CdkDrag 元素,它们是从我组件中数组上的 ngFor 循环呈现的。当我删除一个元素时,我会拼接数组。然后一些元素将更新那里的位置。我该如何避免?

我试图在删除其中一个元素之前获取所有可拖动元素的 freeDragPosition,然后重置它们的位置,但它没有用。

这是我的 app.component.html

<div class="container" id="container">
  <div *ngFor="let f of fields; let i = index;" 
    class="textField"
    [attr.data-guid]="f.guid"  
    (mouseenter)="onFieldHover($event)" 
    cdkDrag 
    cdkDragBoundary="#container"
    (cdkDragEnded)="onDragEnded($event)"
    [cdkDragFreeDragPosition]="f.position">
    <div class="textField-inner">
      <span style="color: hotpink; font-weight: bold">{{f.guid}}</span>
    </div>
    <div class="textField-options">
      <div class="textField-move" cdkDragHandle>
        <svg width="24px" fill="currentColor" viewBox="0 0 24 24">
          <path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"></path>
          <path d="M0 0h24v24H0z" fill="none"></path>
        </svg>
      </div>
      <div class="textField-remove">
        <i class="fas fa-trash-alt" (click)="onRemoveTextField(i)"></i>
      </div>
    </div>
  </div>
</div>
<button type="button" (click)="onTextFieldAdded()">Add a …
Run Code Online (Sandbox Code Playgroud)

drag-and-drop typescript angular-material angular angular-cdk

5
推荐指数
1
解决办法
4443
查看次数

View无法访问Model MVC

我有一个Controller,它返回一个带有如下模型的视图:

    public ActionResult AddSetStory()
    {
        StoryModel sm = new StoryModel();

        return View(sm);
    }
Run Code Online (Sandbox Code Playgroud)

模型为:

namespace AStoryToTell.Views.Stories.StoriesModel
{
    public class StoryModel
    {
        public int IDStory { get; set; }
        public int IDUser { get; set; }
        public string Title { get; set; }
        public string StoryDescription { get; set; }
        public string StoryText { get; set; }
        public string ImagePath { get; set; }
        public IEnumerable<string> Tags { get; set; }
        public string Base64File { get; set; }
        public string FileName …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc annotations

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

FileResult 内容长度不匹配

您好,我使用这篇博文中的代码:

https://blog.stephencleary.com/2016/11/streaming-zip-on-aspnet-core.html

为了使用 .Net core 传输 zip 文件。我成功了,但由于我下载 zip 文件时没有在响应中添加内容长度标头,因此它不会在 chrome 中显示下载进度。因为我提前知道 zip 文件大小,所以我实际上可以使用 SetHeadersAndLog 方法设置内容长度标头 https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.internal.fileresultexecutorbase .setheadersandlog?view=aspnetcore-2.0

但是当我这样做时出现以下错误:

System.InvalidOperationException: Response Content-Length mismatch: too many bytes written (144144633 of 144144627)

知道为什么响应的长度与 zip 文件的长度不同吗?这是提供该文件的代码:

     this._httpContext.Response.ContentType = "application/octet-stream";
            this._httpContext.Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
            this._httpContext.Response.ContentLength = estimatedFileSize;

            FileCallbackResult result = new FileCallbackResult(new MediaTypeHeaderValue("application/octet-stream"), estimatedFileSize, async (outputStream, _) =>
            {
                using (ZipArchive zip = new ZipArchive(outputStream, ZipArchiveMode.Create, false))
                {
                    foreach (string filepath in Directory.EnumerateFiles(existingDirectory.FullName, "*.*", SearchOption.AllDirectories))
                    {
                        string relativepath = filepath.Replace(existingDirectory.FullName + "\\", string.Empty);

                        ZipArchiveEntry zipEntry …
Run Code Online (Sandbox Code Playgroud)

c# http content-length fileresult .net-core

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