小编Gon*_*ica的帖子

带有Lazy-Loaded路由的Angular CLI HMR会重新加载整个内容

(即使使用Angular 7也确认了问题).让我们解决这个问题!

我正在使用HMR设置:https://github.com/angular/angular-cli/wiki/stories-configure-hmr from a ng newbuild build.

如果我更改任何组件并使其延迟加载,角度HMR将热重新加载所有内容,使页面同步更慢.

我知道这是因为它默认设置为console.log每个正在重新加载的模块,当我使用惰性路由时,它会记录所有内容.但是当我将该组件更改为非延迟加载时,它只记录一些小组件.

因此,当我使用HMR和懒惰路由时,我的应用程序需要几秒钟才能刷新.这很烦人.

有没有办法解决?

(懒惰的加载路线是通过这样的方式完成的)

// Main homepage
{
  path: '',
  loadChildren: './public/home/home.module#HomeModule'
},
// ...
Run Code Online (Sandbox Code Playgroud)

(只是一个例子,表明我正在以正确的方式加载)

这里有一些日志记录显示我懒惰加载时会发生什么 home.component.ts

// Everything here is normal, great!
[HMR]  - ../../../../../src/app/public/home/home.component.html
log.js:23 [HMR]  - ../../../../../src/app/public/home/home.component.ts
log.js:23 [HMR]  - ../../../../../src/app/public/home/home.module.ts
log.js:23 [HMR]  - ../../../../../src/app/public/home/home.routing.ts
// Everything below here is NOT normal, bad!  All this is extra.  These are my modules, yes, but all this needs to be loaded again?
log.js:23 …
Run Code Online (Sandbox Code Playgroud)

webpack-hmr angular-cli hot-module-replacement angular angular7

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

VScode 远程连接错误:进程试图写入不存在的管道

我用vscode和remote-ssh连接我的服务器,配置后,我想连接我的主机,但失败了,对话框显示:“无法建立与XX的连接,进程试图写入一个不存在的管道。”

输出:

[16:45:20.916] Log Level: 3
[16:45:20.936] remote-ssh@0.49.0
[16:45:20.936] win32 x64
[16:45:20.944] SSH Resolver called for "ssh-remote+aliyun", attempt 1
[16:45:20.945] SSH Resolver called for host: aliyun
[16:45:20.945] Setting up SSH remote "aliyun"
[16:45:21.012] Using commit id "c47d83b293181d9be64f27ff093689e8e7aed054" and quality "stable" for server
[16:45:21.014] Install and start server if needed
[16:45:21.019] Checking ssh with "ssh -V"
[16:45:21.144] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[16:45:21.214] Running script with connection command: ssh -T -D 5023 aliyun bash
[16:45:21.221] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[16:45:21.504] > 
> …
Run Code Online (Sandbox Code Playgroud)

ssh ssh-keys visual-studio-code vscode-settings vscode-remote

57
推荐指数
5
解决办法
7万
查看次数

从方法访问数据的Vue方式是什么?

我有以下代码:

{
  data: function ()  {
    return {
      questions: [],
      sendButtonDisable: false,
    }
  },

  methods: { 
    postQuestionsContent: function () {
      var that = this;
      that.sendButtonDisable = true;
    },
  },
},
Run Code Online (Sandbox Code Playgroud)

调用sendButtonDisable时我需要更改为true postQuestionsContent().我发现只有一种方法可以做到这一点; 与var that = this;.

有更好的解决方案吗?

javascript methods vue.js

46
推荐指数
3
解决办法
6万
查看次数

Angular 7库 - 如何捆绑依赖项而不将它们添加到主应用程序

我有一个我用它创建的Angular 7应用程序,@angular/cli然后我添加了一个库来使用ng generate library.它在dev模式等方面工作正常.没有问题.

我想保留与包含的库相关的依赖关系; 而不是混乱的主要应用程序package.json.所以,当然,我做npm install --save [xyx]了库文件夹.这工作得很好.仍然在dev模式中运行良好.

但是当我尝试这样做时ng build --prod,突然间它无法找到属于库的依赖项.当然,原因很明显; 他们没有被正确地捆绑在一起.我已经调查npmbundleDependencies功能没有用,我已经看了lib: { embedded: ... }whitelistedNonPeerDependencies选项ng-package.json,但我似乎无法做任何人做我想做什么比较.

这不是成败要求; 如果它是绝对必需的,我将只在主应用程序中安装依赖项.但我非常想避免这种情况.也许这是一个不合理的目标,我不确定.

任何帮助将不胜感激.

angular angular7

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

角度7拖放 - 动态创建掉落区域

有没有办法动态创建拖放区?我在使用ngFor和cdkDropList时遇到了一些麻烦.

这是我的第一个列表和可拖动元素:

       <div class="subj-container" 
        cdkDropListOrientation="horizontal" 
        cdkDropList 
        #subjectList="cdkDropList"
        [cdkDropListData]="subjects"  
        [cdkDropListConnectedTo]="[lessonList]" 
        (cdkDropListDropped)="drop($event)"
        >
            <div class="subject" *ngFor="let subject of subjects" cdkDrag>
                {{subject.name}}
            </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

这是我的第二个清单:

          <div class="conta" cdkDropList
                #lessonList="cdkDropList"
                [cdkDropListData]="appointment.lessons"
                [cdkDropListConnectedTo]="[subjectList]"
                (cdkDropListDropped)="drop($event)">
                    <div class="sub" cdkDrag *ngFor="let lesson of appointment.lessons">
                        {{lesson.name}}
                </div>
           </div>
Run Code Online (Sandbox Code Playgroud)

现在,带有'conta'类的div在*ngFor中.

我想,我的问题是我的第二个清单.如果我将一个元素从第二个列表拖到列表一,它可以正常工作,但如果我尝试将元素从列表一拖到第二个列表中的任何列表实例,它就无法识别该元素是否被拖动.在这里演示:

问题演示

我在这里做错了吗?打字稿部分工作正常.

谢谢

drag-and-drop angular angular-cdk angular7

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

角度材质样式未正确应用

任何想法为什么没有正确应用角度材料样式?

我知道对此有很多问题,但我似乎无法找到解决我问题的方法。我已经在几个项目中毫无问题地使用了角度材料,但似乎无法弄清楚这里发生了什么。
我可能忽略了一些简单的东西,但就是看不到它。我刚刚升级到 angular 7,所以它可能与此有关。

这是我的对话框,它只显示在带有奇怪或没有样式的父页面中。它正在做一些事情,因为与取消按钮相比,您可以看到按钮略有变化。

在此处输入图片说明

<div>
  <h4 mat-dialog-title>New Course Item</h4>
</div>
<div mat-dialog-content>
    <div>
        <div>
          <mat-form-field>
              <mat-label>Title</mat-label>
              <input type="text" [(ngModel)]="newCourseItem.title" #title="ngModel" matInput required placeholder="Title" name="title"/>
              <mat-error *ngIf="title.hasError('required')">This field is required</mat-error>
          </mat-form-field>
        </div>
        <div>
          <button (click)="this.dialogRef.close()">Cancel</button>
          <button mat-raised-button color="primary" [mat-dialog-close]="newCourseItem" cdkFocusInitial>Add New</button>
        </div>
      </div>
</div>

import { CourseItem } from './../../../../models/course-item';
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';

@Component({
  selector: 'app-new-course-item-dialog',
  templateUrl: './new-course-item-dialog.component.html',
  styleUrls: ['./new-course-item-dialog.component.css']
})
export class NewCourseItemDialogComponent implements OnInit { …
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular7

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

jQuery将类添加到当前li并在li a中单击时删除prev li

这是html:

<ul>    
    <li class="current"><a href="#">menu item</a></li>  
    <li><a href="#aba">menu item</a></li>
    <li><a href="#abb">menu item</a></li>
    <li><a href="#abc">menu item</a></li>
    <li><a href="#abd">menu item</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

如果我按'a'链接,它会添加类'当前'来点击li并删除旧的li类?这是我的尝试:

$('ul li a').click(function(){
  $('ul li').removeClass('current');
  ... don't know here (add class to current li) ...
});
Run Code Online (Sandbox Code Playgroud)

html jquery

12
推荐指数
2
解决办法
9万
查看次数

JupyterLab 中 Plotly 的正确扩展是什么?

Plotly 无法在 Jupyterlab 中运行。我认为所需的扩展存在冲突,但我不确定。在 Plotly https://plotly.com/python/troubleshooting/上检查故障排除时,他们建议删除扩展并再次安装。但我发现 Jupyterlab 更新附带了一个名为“ jupyterlab-plotly-extension ”的附加扩展,Plotly 在其说明中没有提到该扩展,以使其在 JupyterLab 中工作https://plotly.com/python/getting-started/ #jupyterlab-support-python-35

我的问题是:应该安装哪些扩展才能使 Plotly 在 JupyterLab 中工作?

  • Plotly 支持中提到的 jupyterlab-plotly
  • JupyterLab 附带的 jupyterlab-plotly-extension

python libraries plotly jupyter jupyter-lab

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

使用 Angular 下载 .xls 文件:JSON.parse (&lt;anonymous&gt;) 位置 0 处的 JSON 中的意外令牌 P

我有一个返回以下服务器方法byte[]xls存储在文件Azure Blob Storage

[FunctionName("ReadBatchFile")]
        public async static Task<HttpResponseMessage> ReadBatchFile([HttpTrigger(AuthorizationLevel.Function, WebRequestMethods.Http.Get, Route = "Agreements/ReadBatchFile")]HttpRequestMessage req, TraceWriter log)
        {
            try
            {
                var fileName = req.GetQueryNameValuePairs()
                   .FirstOrDefault(q => string.Compare(q.Key, "fileName", true) == 0)
                   .Value;
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new ByteArrayContent(await AzureHelpers.ReadFromBlobStorage(fileName));  //returns byte[] 
                response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") { FileName = fileName };
                response.Content.Headers.ContentType =
                    new MediaTypeHeaderValue("application/octet-stream");
                return response;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                req.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return req.CreateResponse(HttpStatusCode.BadRequest);
        }
Run Code Online (Sandbox Code Playgroud)

从上面可以看出, the response.Contentis set …

c# json http typescript angular

10
推荐指数
2
解决办法
9437
查看次数

由于非 https 网址,自定义 Tumblr 主题无法保存?

所以昨天我很高兴地编辑了我的 tumblr 博客的主题,一切正常。今天进入同一个博客,当我点击保存时它会出现这个:“哦!我们无法保存您的主题。看起来您的自定义主题引用了来自非 HTTPS 网址的资产。请仅使用 HTTPS 网址重试。” 超级混乱,因为从昨天开始就没有添加 url,然后一切都很好。我的其他具有自定义主题的博客也发生了同样的事情。我什至浏览并删除了 html 页面上的所有 url,只是为了看看它是否会做任何事情,并且出现了相同的警报。到底是怎么回事 ??

请帮忙

干杯

html url https http tumblr

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