可以说我们有两个接口:
interface WithStringArray1 {
property: [string]
}
interface WithStringArray2 {
property: string[]
}
Run Code Online (Sandbox Code Playgroud)
让我们声明一些这些类型的变量:
let type1:WithStringArray1 = {
property: []
}
let type2:WithStringArray2 = {
property: []
}
Run Code Online (Sandbox Code Playgroud)
第一次初始化失败了:
TS2322: Type '{ property: undefined[]; }' is not assignable to type 'WithStringArray1'.
Types of property 'property' are incompatible.
Type 'undefined[]' is not assignable to type '[string]'.
Property '0' is missing in type 'undefined[]'.
Run Code Online (Sandbox Code Playgroud)
第二个是好的.
[string]和之间有什么区别string[]?
ng-repeat显示div元素时,我遇到了多个元素的问题inline-block.元素之间存在奇怪的差距,其中一个ng-repeat结束并且下一个元素开始,如图像所示:

我创建了一个plunk来演示这种行为:
为什么会发生这种情况以及如何消除这种差距?
我正在尝试运行 typescript 文件(在应用程序内),该文件依赖于 NX 的几个库,但我不知道该怎么做。我尝试了很多方法,以下是我尝试过的几种方法:
第一次尝试
"cron": {
"executor": "nx:run-commands",
"options": {
"command": "ts-node apps/src/cron.ts"
}
},
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
node:internal/modules/cjs/loader:959
throw err;
^
Error: Cannot find module './cron.ts'
Require stack: ...
Run Code Online (Sandbox Code Playgroud)
第二次尝试
我还尝试过以下操作:
"build": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"platform": "node",
"target": "node14",
"outputPath": "dist/apps/cron",
"tsConfig": "apps/cron/tsconfig.app.json",
"main": "apps/crons/src/cmd/run-token-trade-counts-cron.ts"
}
},
Run Code Online (Sandbox Code Playgroud)
这次它成功编译了,但是当我运行可执行文件时出现以下错误:
nx run cron:cron
Error: Cannot find module '@company/logger'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?
谢谢
当我想在 Angular 中创建自定义表单控件时,我需要实现ControlValueAccessorwhich DefineswriteValue(value:any): void函数。
现在想象一下,由于其内部工作原理,自定义组件仅接受仅包含数字的字符串。它不能接受任何其他东西,因为它不能用它做任何有意义的事情。
当有人调用formControl.setValue()无效值时的问题:
formControl(null或无效输入)应该是什么?writeValue调用onChange回调,以便 Angular 知道该值未被接受?null我有两条线:AB和BC
我可以计算特定距离线的法线 - D1和D2.
我需要计算点D的x,y坐标
.
我想我可以通过绕点B旋转D2来计算它.

但我不知道怎么做.
typescript ×2
angular ×1
angularjs ×1
css ×1
geometry ×1
html ×1
javascript ×1
math ×1
monorepo ×1
tsconfig ×1