小编vul*_*ulp的帖子

如何在 getReducers(): ActionReducerMap<fromFeature.State> 中返回减速器的映射?

我试图在通过 NgRx 功能模块组合状态时注入功能减少器。

import { NgModule, InjectionToken } from '@angular/core';
import { StoreModule, ActionReducerMap } from '@ngrx/store';

import * as fromFeature from './reducers';

export const FEATURE_REDUCER_TOKEN = new InjectionToken<ActionReducerMap<fromFeature.State>>('Feature Reducers');
Run Code Online (Sandbox Code Playgroud)

我应该在这里返回什么?

export function getReducers(): ActionReducerMap<fromFeature.State> {
  // map of reducers
  return {
  
  };
}
Run Code Online (Sandbox Code Playgroud)

我试过

export function getReducers(): ActionReducerMap<fromFeature.State> {
      // map of reducers
      return {
          reducerA: FeatureAReducer
      };
    }
Run Code Online (Sandbox Code Playgroud)

但它给出了错误Object literal may only specified known properties

其余模块代码:

@NgModule({
  imports: [
    StoreModule.forFeature('feature', FEATURE_REDUCER_TOKEN),
  ],
  providers: [ …
Run Code Online (Sandbox Code Playgroud)

ngrx ngrx-store

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

为什么 nginx sub_filter 不适用于 proxy_pass?

目标

我想绕过通过反向代理的同源策略iframe以便对iframe.

问题一

srciframe 的设置为https://example1.com/iframe-app. 但这仍然会在浏览器中引发同源策略违规。所以浏览器仍然会看到 iframe 中的页面,因为它不是源自https://example1.com/,这似乎没问题,因为如果底层页面具有相同的来源,那么它的 ajax 请求将不起作用。

问题二

所以我尝试使用 nginxsub_filter指令将我的 javascript 注入响应 html。但是,没有在响应中添加任何内容。也许这是因为响应是由于 https 协议而加密的?

为什么sub_filter不起作用以及如何使其工作?

nginx 配置

server {
    
            root /var/www/example1.com/html;
            index index.html index.htm index.nginx-debian.html;
    
            server_name example1.com www.example1.com;
    
    
            location / {
                    proxy_pass http://localhost:4000;
            }
    
            location /iframe-app {
                    rewrite ^/iframe-app(.*) /$1 break;

                    proxy_pass http://example2.com;
                    
                    proxy_set_header Accept-Encoding "";
                    
                    proxy_redirect off;
                    
                    sub_filter '</head>' '<script>...code</script></head>';
                    sub_filter_once on;
                    sub_filter_types text/html;
    
            }
    
    
        listen [::]:443 ssl ipv6only=on; …
Run Code Online (Sandbox Code Playgroud)

javascript iframe nginx

7
推荐指数
0
解决办法
1068
查看次数

如何重定向到 ASP.NET Core WebAPI 中的操作?

我的 ASP.NET Core Web API 应用程序的控制器中有两个操作:

[HttpGet("get-all")]
public IActionResult GetAll() { ... }
Run Code Online (Sandbox Code Playgroud)

[HttpDelete("{id}")]
public IActionResult Delete(int id)
{
    ...

    return RedirectToAction("GetAll"); 
}
Run Code Online (Sandbox Code Playgroud)

Delete动作总是重定向到它自己,而不是重定向到GetAll。为什么这样?同时,类似的来自Post操作的重定向也可以正常工作。

找不到有关该主题的任何文档。有什么帮助吗?

asp.net-web-api-routing asp.net-core asp.net-core-webapi

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

如何解释这些 TypeScript 声明中的 [p in keyof T] 和 T[p]?

我正在阅读ngrx文档并偶然发现了这样的代码。什么[p in keyof T]T[p]意味着什么呢?

export type ActionReducerMap<T, V extends Action = Action> = {
  [p in keyof T]: ActionReducer<T[p], V>
};
Run Code Online (Sandbox Code Playgroud)

typescript ngrx

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

如何在 Angular 模板中嵌入 GitHub gist?

Angular 会忽略script其模板中的标签,但需要它们来加载 GitHub gist。执行此操作的最佳做​​法是什么?使用iframescript动态创建标签?或者是其他东西?

javascript gist github embedding angular

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

QuillJs - 跳到顶部

我在我的网站上使用 QuillJs 作为文本编辑器。在长帖子中,当粘贴文本或更改标题类型或对齐方式或颜色或插入链接或视频时,屏幕视图会跳到顶部。无法找出原因。

QuillJs 版本:1.2.6 浏览器:Chrome 58.0.3029.110 操作系统:Windows 10

初始化:

var toolbarOptions = [
    [{ 'header': [1, 2, 3, 4, 5, 6, false] },
       'bold', 'italic', 'underline', 'strike', { 'align': [] },
        { 'list': 'ordered' }, { 'list': 'bullet' },
        { 'color': [] }, { 'background': [] }], 

        ['image', 'blockquote', 'code-block', 'link', 'video'],

        ['clean']                                           
    ];
var quill = new Quill('#editor', {
    modules: {
      toolbar: toolbarOptions
    },
    theme: 'snow'
});
Run Code Online (Sandbox Code Playgroud)

或者,也许您可​​以为网站推荐一个更好的简单且免费的 html 编辑器?我不喜欢 CKE 或 Tinymce。

javascript rich-text-editor quill

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

为什么 sanitizer.bypassSecurityTrustStyle 在设置 [style.background-image] 属性时返回警告?

我有一段简单的代码无法工作:

<div class="cover"
    [style.background-image]="sanitizer.bypassSecurityTrustStyle('url(/assets/img/picture (1).jpg)')">
</div>
Run Code Online (Sandbox Code Playgroud)

返回sanitizer.bypassSecurityTrustStyle以下消息:

SafeValue must use [property]=binding: url(/assets/img/picture (1).jpg) (see http://g.co/ng/security#xss)
Run Code Online (Sandbox Code Playgroud)

还尝试将消毒转移到自定义管道,结果是相同的。

当尝试以下解决方案时,Angularstyle.background-image完全忽略:

  1. [style.background-image]="'url(' + photo + ')'"
  2. [ngStyle]="{'background-image': 'url(' + photo + ')'}"

为什么?

角度:5.2.4

sanitization angular

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