小编kyw*_*kyw的帖子

Visual Studio代码:热键可以将选项卡从两个拆分编辑器之一移动到另一个编辑器?

假设我将编辑器分成两半,左右两边,我想将一个从左侧编辑器中打开的文件移动到右侧的编辑器,反之亦然.

visual-studio-code

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

检查FormGroup是否已提交

在模板驱动的形式,我们可以检查与submitted属性NgForm.但是如何以模型驱动的形式实现呢?

angular

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

control.registerOnChange 不是函数

我正在构建一个自定义地址组件。我在一个组件中使用它:

消费者.component.html:

<form [formGroup]="form">
  <nt-address [parent]="form" fG="addrGrp" formControlName="addrGrp"></nt-address>
  {{form.value | json}}
</form>
Run Code Online (Sandbox Code Playgroud)

消费者.component.ts

data = {
 addr1: 'Sample Address Line 1'
};
ngOnInit() {
  this.form = this.fb.group({
    addrGrp: this.fb.group(this.data)
  })
}
Run Code Online (Sandbox Code Playgroud)

nt-address.component.html:

<div [formGroup]="parent">
   <div [formGroupName]="fG">
     <md-input-container>
       <input mdInput type="text" formControlName="addr1" placeholder="Address Line 1">
     </md-input-container>
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

nt-address.component.ts:

export class AddressComponent extends ValueAccessorBase<any> {
   @Input() parent: FormGroup;
   @Input() fG: FormGroup;

}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

类型错误:control.registerOnChange 不是函数

angular

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

Lit-Element:如何设置全局/重置 css

如果我使用 Lit-element,当前设置全局/重置 CSS 的最佳实践是什么?

我已经尝试过 1) 将它们内联到<style>我的文档根目录中,2) 像这个答案一样构建样式表

<script>
  var css = new CSSStyleSheet()
  css.replace('@import url("./style/static/reset.css")')
  document.adoptedStyleSheets = [css]
</script>
Run Code Online (Sandbox Code Playgroud)

但没有任何作用...

编辑 我的reset.css

blockquote,
body,
dd,
dl,
fieldset,
figure,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
legend,
p,
pre,
button,
ul {
  margin: 0;
  padding: 0;
}

img {
  max-width: 100%;
}
Run Code Online (Sandbox Code Playgroud)

我建立在来自https://open-wc.org/guide/#quickstart的文件夹结构脚手架之上

web-component lit-element

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

模拟内部axios.create()

我正在使用jestaxios-mock-adapter测试异步动作创建器中的axiosAPI调用redux.

当我使用axios这样创建的实例时,我无法使它们工作axios.create():

import axios from 'axios';

const { REACT_APP_BASE_URL } = process.env;

export const ajax = axios.create({
  baseURL: REACT_APP_BASE_URL,
});
Run Code Online (Sandbox Code Playgroud)

我会用它来消费它async action creator:

import { ajax } from '../../api/Ajax'

export function reportGet(data) {
  return async (dispatch, getState) => {
    dispatch({ type: REQUEST_TRANSACTION_DATA })

    try {
      const result = await ajax.post(
         END_POINT_MERCHANT_TRANSACTIONS_GET,
         data,
      )
      dispatch({ type: RECEIVE_TRANSACTION_DATA, data: result.data })
      return result.data
    } catch (e) {
      throw …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs jestjs axios create-react-app

5
推荐指数
3
解决办法
4272
查看次数

如何动态扩展或组合 Yup 模式

说我有一个Yup.string()开始。

然后,在某些时候,就像在循环中一样,我想required向它添加规则,有效地:

Yup.string().required('This field is required').

也许然后也添加一些.email检查。

我已经尝试过这种方式,但似乎没有用:

function validationSchemaConstructor(question) {
  const schema = Yup.string();

  question.validation_rules.forEach(rule => {
    if ("is_required" in rule) {
      schema.required("Hey man nice shot");
    }
  });

  return schema;
}
Run Code Online (Sandbox Code Playgroud)

validation reactjs yup formik

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

Angular 2:将属性指令的值传递为组件变量

所以我appGetCurrency在这里有一个属性指令:

<md-select appGetCurrency [(ngModel)]="value" placeholder="Currency" name="currency">
  <md-option *ngFor="let c of currencyList" [value]="c.code">{{c.dsc}}</md-option>
</md-select>
Run Code Online (Sandbox Code Playgroud)

我希望该appGetCurrency指令将一些值传递给它currencyList以构建选项列表.

编辑

appGetCurrency指令只是获取服务中的货币列表,然后我想将该列表传递给currencyList主机模板中的变量:

@Directive({ selector: '[appGetCurrency]' })

export class CurrencyDirective {
  currencies;

  constructor() {
    // build the <md-options> based on 'currencies' 
    this.currencies = this.service.getCurrencies('asia'); 
  }

}
Run Code Online (Sandbox Code Playgroud)

angular2-directives angular

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

正则表达式:匹配除第一个换行符之外的所有换行符

假设我有这样的文本块:

* hello

  
world



hello again
Run Code Online (Sandbox Code Playgroud)

在 Javascript 中使用 RegEx,如何\在所有平台中替换除第一个之外的所有段落之间的新行?

那么有效的结果就是,

* hello

\
world

\
\
hello again
Run Code Online (Sandbox Code Playgroud)

javascript regex

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

d3js v4:仅在 x 轴上显示标签

我正在创建一个堆积条形图。我只想在 x 轴上显示刻度的标签文本,但没有刻度和水平 x 轴线。

我从这里怎么走?

g.append('g')
  .attr('class', 'axis')
  .attr('transform', 'translate(0,' + height + ')')
  .call(d3.axisBottom(x));
Run Code Online (Sandbox Code Playgroud)

d3.js

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

如何在 Gatsby 中集成 whatwg-fetch

有谁知道如何whatwg-fetch在 gatsby 中集成fetch polyfill?

到目前为止我所做的是import 'whatwg-fetch';gatsby-browser.js. 现在我不确定如何将它添加为 webpackentry属性中的第一个元素,大概在gatsby-node.js.

reactjs gatsby

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

Material2:如何覆盖Material2组件中的Roboto字体

我想改用Lato.我试图在增加它index.htmlstyles.css,但不工作.

angular-cli angular-material2 angular

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