我正在尝试为我的模拟服务器设置别名。每当我尝试编译ts文件时,它都会返回找不到正确模块的错误,即使这些模块是在tsconfig,json->中定义的paths
文件夹结构:
??? server
? ??? src
? ???/json
??? src
? ???/modules
??? tsconfig.json
Run Code Online (Sandbox Code Playgroud)
这是我的 tsconfig.json
{
"compilerOptions": {
"baseUrl": "./src",
"experimentalDecorators": true,
"jsx": "react",
"lib": [
"dom",
"es2015",
"es2015.promise"
],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"paths": {
"@project/app/modules/*": [
"modules/*"
],
"@project/server/data/*": [
"../server/src/json/*"
]
},
"sourceMap": true,
"target": "es5"
},
"exclude": [
"node_modules",
"tools"
]
}
Run Code Online (Sandbox Code Playgroud)
错误:
Error: Cannot find module '@project/server/data/accounts/accountsList'
我正在尝试使用全局Intl构造函数来格式化带有货币的值。但它似乎currencyDisplay:'narrowSymbol'不受支持并且在 Safari 中工作,但在 Chrome 中工作正常。
在控制台中返回以下错误:
RangeError: currencyDisplay must be either "code", "symbol", or "name"
我正在尝试从API加载值后更新表单值.我尝试使用该*ngIf技术,但即使设置了表单,表单也不可见.
我无法共享整个项目,但这里是组件模板和控制器
模板
<div class="page-title">
<h3> Edit news </h3>
</div>
<div class="partner-add-form">
<ng-container *ngIf='newsForm'>
<form action="" [formGroup]='newsForm' (ngSubmit)="onSubmit()">
<div class="row ">
<div class="input-field col s12 tooltip">
<input formControlName='title' [id]="'title'" [type]="'text'">
<label [for]="'title'">Title</label>
<validator-errors [control]='newsForm.get("title")'></validator-errors>
</div>
<div class="input-field col s12 tooltip">
<textarea class="materialize-textarea" formControlName='content' [id]="'content'"></textarea>
<label [for]="'content'">Content</label>
<validator-errors [control]='newsForm.get("content")'></validator-errors>
</div>
<div class="input-field col s12 margin-reset">
<mat-form-field class="full-width">
<mat-select [formControl]='newsForm.controls["partner_id"]'>
<mat-option disabled selected>Categories</mat-option>
<mat-option *ngFor="let partner of partners.data" [value]="partner.id">
{{ partner.name }} </mat-option>
</mat-select>
</mat-form-field>
<validator-errors [control]='newsForm.controls["partner_id"]'></validator-errors>
</div>
<div class="file-field …Run Code Online (Sandbox Code Playgroud) "react-router": "5.0.1",
<Switch>
<Route
component={TestComponent}
key={TestComponentPath}
path={TestComponentPath}
exact
/>
{
exampleCondition && (
<>
<Route
component={TestComponent2}
key={TestComponentPath2}
path={TestComponentPath2}
exact
/>
<Route
component={TestComponent3}
key={TestComponentPath3}
path={TestComponentPath3}
exact
/>
</>
)
}
<Redirect to={redirectUrl} />
</Switch>
Run Code Online (Sandbox Code Playgroud)
显示示例Switch、Redirect用例。
redirectUrl如果没有匹配的路径,应该重定向到给定的路径。
其行为就像Redirect在 switch 末尾没有提供 no 一样。问题可能是由于React.Fragment里面已经使用过造成的Switch。删除后重定向工作正常。
javascript ×2
reactjs ×2
typescript ×2
alias ×1
angular ×1
currency ×1
intl ×1
react-router ×1
safari ×1
ts-node ×1
tsc ×1
tsconfig ×1