小编Jam*_*rov的帖子

找不到在 tsconfig `paths` 中定义的模块

我正在尝试为我的模拟服务器设置别名。每当我尝试编译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'

alias typescript tsc tsconfig ts-node

35
推荐指数
7
解决办法
5万
查看次数

货币显示必须是“代码”、“符号”或“名称”——Safari 问题

我正在尝试使用全局Intl构造函数来格式化带有货币的值。但它似乎currencyDisplay:'narrowSymbol'不受支持并且在 Safari 中工作,但在 Chrome 中工作正常。

在控制台中返回以下错误:
RangeError: currencyDisplay must be either "code", "symbol", or "name"

javascript safari currency intl reactjs

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

加载数据后设置反应形式(异步) - Angular 5

我正在尝试从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)

typescript angular2-forms angular angular-reactive-forms

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

使用 Fragment 后,重定向在 Switch 内不起作用

版本

"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)

重现步骤

显示示例SwitchRedirect用例。

预期行为

redirectUrl如果没有匹配的路径,应该重定向到给定的路径。

实际行为

其行为就像Redirect在 switch 末尾没有提供 no 一样。问题可能是由于React.Fragment里面已经使用过造成的Switch。删除后重定向工作正常。

沙箱示例

https://codesandbox.io/s/react-router-tklng

javascript reactjs react-router

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