假设我将编辑器分成两半,左右两边,我想将一个从左侧编辑器中打开的文件移动到右侧的编辑器,反之亦然.
我正在构建一个自定义地址组件。我在一个组件中使用它:
消费者.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 不是函数
如果我使用 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的文件夹结构脚手架之上
我正在使用jest并axios-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) 说我有一个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) 所以我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) 假设我有这样的文本块:
* hello
world
hello again
Run Code Online (Sandbox Code Playgroud)
在 Javascript 中使用 RegEx,如何\在所有平台中替换除第一个之外的所有段落之间的新行?
那么有效的结果就是,
* hello
\
world
\
\
hello again
Run Code Online (Sandbox Code Playgroud) 我正在创建一个堆积条形图。我只想在 x 轴上显示刻度的标签文本,但没有刻度和水平 x 轴线。
我从这里怎么走?
g.append('g')
.attr('class', 'axis')
.attr('transform', 'translate(0,' + height + ')')
.call(d3.axisBottom(x));
Run Code Online (Sandbox Code Playgroud) 有谁知道如何whatwg-fetch在 gatsby 中集成fetch polyfill?
到目前为止我所做的是import 'whatwg-fetch';在gatsby-browser.js. 现在我不确定如何将它添加为 webpackentry属性中的第一个元素,大概在gatsby-node.js.
我想改用Lato.我试图在增加它index.html和styles.css,但不工作.
angular ×4
reactjs ×3
javascript ×2
angular-cli ×1
axios ×1
d3.js ×1
formik ×1
gatsby ×1
jestjs ×1
lit-element ×1
regex ×1
validation ×1
yup ×1