小编Edo*_*don的帖子

c #automapper字典到字典

我试图将Superhero模型自动映射到Supervillan模型,每个模型都有类似的字典声明:

超级英雄:

public class Superheroes {
    public Dictionary<string, SomeHero>> SuperNumber {get; set;}
}

public class SomeHero {
 // unique properties
}
Run Code Online (Sandbox Code Playgroud)

Supervillan:

public class Supervillans {
    public Dictionary<string, SomeVillan>> SuperNumber {get; set;}
}

public class SomeVillan {
 // unique properties
}
Run Code Online (Sandbox Code Playgroud)

我尝试在其他类似的线程中遵循建议,但没有成功.这是我最近的尝试,执行失败:

CreateMap<KeyValuePair<string, Superheroes>, KeyValuePair<string, Supervillans>>(); 
Run Code Online (Sandbox Code Playgroud)

如何将我的超级英雄SuperNumber字典映射到我的Supervillan SuperNumber字典?

注意:SomeHero/SomeVillan模型将具有独特的属性,但我对此问题并不关心它们.

c# dictionary automapper

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

在 package.json 中创建子文件夹

在我的 package.json(来自 npm)中,我有以下构建命令:

"build": "mkdir -p ./build && cp ./src/index.html ./build/ && webpack -p --config webpack.production.config.js"
Run Code Online (Sandbox Code Playgroud)

这个命令运行得很好,并创建了一个几乎包含我需要的所有东西的“build”文件夹。

但是,我还需要让 build 命令创建一个名为 "images"的子目录(在build文件夹中)。

我尝试了一些事情,例如以下内容:

 "build": "mkdir build && mkdir -p ./build/images && cp src/index.html build/ && webpack -p --config webpack.production.config.js"
Run Code Online (Sandbox Code Playgroud)

它总是返回这个错误

如何更改此构建命令以在构建文件夹中创建子目录?

json build node.js npm

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

Angular 2焦点和输入元素的模糊

我在Angular 2中编写了一个具有占位符值的输入字段.

在焦点上,输入字段应为空.

在模糊时,输入字段应返回占位符值.

但是,在模糊时没有任何反应.这是我的输入字段:

<input type="text" 
       placeholder={{placeholderText}}
       onfocus="this.placeholder = ''" 
       (blur)="this.placeholder = placeholderText">
Run Code Online (Sandbox Code Playgroud)

如何在Angular 2中更改模糊的占位符文本?

html javascript angular

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

在加载组件之前等待 VueX 值加载

当用户尝试直接导航加载组件 url 时,我的 vuex 操作中会进行一个 http 调用,一旦它解析,它将在我的状态中定义一个值。

在解析 http 调用并定义状态值之前,我不想加载我的组件。

例如,在我的组件中

export default {
  computed: {
    ...mapState({
      // ** this value needs to load before component mounted() runs **
      asyncListValues: state => state.asyncListValues
    })
  },

  mounted () {
    // ** I need asyncListValues to be defined before this runs **
    this.asyncListValues.forEach((val) => { 
      // do stuff
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

asyncListValues在加载我的组件之前,如何让我的组件等待加载?

javascript vue.js vue-router vuex vuejs2

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

Remix 使用提交任意数据

我正在尝试使用 Remix 的 useSubmit 挂钩提交表单。但我希望能够随表单提交数据一起传递任意数据。

我有一些带有禁用/只读属性的静态值的表单元素,这意味着在表单提交时它们的值将为空。不过,我可以在变量中访问它们的实际值post,我想将其发送到我的操作。

export const action: ActionFunction = async (request) => {
  // I want access to {arbitraryData} here passed from submit
}

export default function EditSlug() {
  const post = useLoaderData();

  // ...Submit handler passing arbitrary data (post.title in this case)
  const handleSubmit = (event: any) => {
      submit(
        { target: event?.currentTarget, arbitraryData: post.title },
        { method: "post", action: "/admin/edit/{dynamicRouteHere}" }
      );
    };

  return(
  <Form method="post" onSubmit={handleSubmit}>
            <p>
              <label>
                Post Title:
                <input
                  type="text"
                  name="title" …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs remix.run

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

我可以将哪个版本的 NgRx 与 Angular 4 一起使用

最新版本的 NgRx/store,特别是 NgRx 是否与 Angular 4 兼容?如果没有,我需要将哪个版本的 NgRx 与 Angular 4 一起使用?

另外,NgRx/store 4 与版本 6 有很大不同吗?例如,如果我学习版本 6,过渡到版本 4 会遇到困难吗?

抱歉,如果这个问题太基础了,我无法通过谷歌找到答案。

ngrx angular

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

Chrome 扩展在所有选项卡中设置切换开关状态

我正在制作一个简单的 Chrome 扩展程序,其中包含一个简单的开/关开关,见下文:

在此处输入图片说明

每当我启用此开关时,我都希望它的新开/关状态反映在所有其他活动选项卡/新选项卡/chrome 实例中。

这目前没有发生,如果我在一个选项卡中启用它,它仍然在另一个选项卡中被禁用。

我的方法如下:

  1. 将事件侦听器添加到交换机

  2. 切换值,并将新值存储在 chrome.storage 中

  3. chrome.runtime向后台脚本发送消息,并更新所有 chrome 实例。

问题:每当我切换开关时,我都会收到以下错误:

在此处输入图片说明

此外,出于某种原因,我的 background.js 从未初始化,可能与上述错误有关。

这是我的

background.js(侦听要发送的消息,以便我可以更新其他选项卡)

console.log('?! loading background js !?') // this never fires :(

// Whenever a message has been passed, such as toggling the enable/disable switch, communicate that with other Chrome tabs/instances.
chrome.runtime.onMessage.addListener(
    function (request, sender, sendResponse) {
        // todo: update all chrome tabs with new switch state
        console.log('reached Background message handler!')
    }
);
Run Code Online (Sandbox Code Playgroud)

popup.js(监听点击事件,执行切换 chrome.storage 切换值的脚本)

// when …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome google-chrome-extension

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

Angular 2中带有箭头键的html列表项选择

我试图通过箭头键选择li的,但是遇到了问题。

我尝试按照此处的答案进行操作,但我的李从未被选中。

对于以下代码,我只是想使(keydown)正常工作。

这是我的:

landingpage.component.html

<div class="searchArea">
  <input type="text" autoComplete="off" (keydown)="keyDown($event)" placeholder={{backgroundPlaceholder.info.placeholderText}} [(ngModel)]="keystroke"
    (ngModelChange)="getKey($event)">
  <div class="results-list">
    <li *ngFor="let list of shows; let i = index" [class.active]="i == {{arrowkeyLocation}}">
      <span class="result">{{list.show}}</span>
    </li>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

landingpage.component.ts

arrowkeyLocation = 0;

 keyDown(event) {
   return this.arrowkeyLocation++; 
 } 
Run Code Online (Sandbox Code Playgroud)

照原样,当我按下向下键时,什么也没有选择。我很确定问题出在我的html [class.active]中,但我不确定如何解决。

如何通过箭头键选择li元素?

html javascript html-lists angular

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