对于html:
<body>
<div>
<div>
<div>
...
</div>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
有没有办法创建一个使用其父值的递归变量:
body > div {
--x: 1;
}
div {
--x: calc(var(--x) + 1);
}
Run Code Online (Sandbox Code Playgroud)
以上内容无效,因为css变量不能具有依赖循环.另一个无效的例子
body > div {
--is-even: 0;
--is-odd: 1;
}
div {
--is-even: var(--is-odd);
--is-odd: var(--is-even);
}
Run Code Online (Sandbox Code Playgroud)
是否有任何间接方式在css中表达这样的递归变量?
当我在 JavaScript 或 TypeScript 中重命名变量时,VS Code 有时会在解构赋值中添加别名:
const { renamedProp: prop } = arg; // After rename
Run Code Online (Sandbox Code Playgroud)
或者它添加as了进口:
import { Foo as renamedFoo } from "./file"; // After rename
Run Code Online (Sandbox Code Playgroud)
为什么 VS Code 会这样做,我该如何禁用这种行为?例如,如果我prop在界面中重命名Foo以下代码:
export interface Foo {
prop: string;
}
function bar(arg: Foo) {
const { prop } = arg;
return prop;
}
Run Code Online (Sandbox Code Playgroud)
VS Code 将代码更改为:
export interface Foo {
renamedProp: string;
}
function bar(arg: Foo) {
const { renamedProp: prop } = arg; …Run Code Online (Sandbox Code Playgroud) 我在 VSCode 中打开了远程 SSH 工作区,但我的一些扩展未启用。例如,我安装了Python和Go扩展,但当我连接到远程 ssh 工作区时,它们不起作用。使用开发容器或 WSL 的远程工作区也会发生同样的情况。
如何在远程工作区中启用这些扩展?
我已经为我的项目创建了一个 VS Code开发容器。为了帮助新贡献者开始,开发容器 Dockerfile 应该运行吗npm install?
我正在寻找一种加权随机选择算法,该算法具有与别名方法类似的特性,除非在选择项目后将其删除.
例如,我有一个包产生:
我对袋子进行取样并得到一块红色大理石.红色现在已被删除,所以我想现在这个包会产生:
我相信你可以预先计算每个可能的概率表的树,以便样本仍然存在O(1).是否有更聪明的算法用于恒定时间加权选择和删除?
我的项目结构是src/client/modules/server/app.ts
src/
client/
modules/
DB/
server/
app.ts
tsconfig.json
Run Code Online (Sandbox Code Playgroud)
我在 app.ts 文件中使用非相对导入导入一个模块
import * as DB from '@modules/DB';
Run Code Online (Sandbox Code Playgroud)
因为我不想使用 from "../modules/DB"
我的 tsconfig.json 是
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"target": "ES6",
"noImplicitAny": true,
"sourceMap": true,
"preserveConstEnums": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"traceResolution": true,
"rootDir": "./src",
"outDir": "./dist",
"declaration": true,
"typeRoots": [
"/"
],
"baseUrl": "./src",
"paths": {
"@modules/*": [
"modules/*"
]
}
},
"exclude": [
"src/client/"
]
Run Code Online (Sandbox Code Playgroud)
}
当我追踪分辨率时,得到了这个
======== Module name '@modules/DB' was successfully resolved to …Run Code Online (Sandbox Code Playgroud) 在 sublime 中使用 PHP 或 JavaScript 文件时,如果我输入以下代码:
$test = "Scott";
If($test == null) {
$test2 = "Scott"
}
Run Code Online (Sandbox Code Playgroud)
当我输入“$test2 = 'Sc...”时,Sublime 会自动补全“Scott”,因为它是在当前文档范围内作为字符串找到的一个词。
但是,当我在 VSCode 中进行相同的测试时,它并没有选择它或提供任何建议。这在 VSCode 中可能吗?我已经在首选项中打开了所有 true 的快速建议。我不确定我还能在这里做什么,或者我是否需要下载其他插件。谢谢!
我的智能感知有问题我已经禁用了所有扩展,但我仍然得到:
抱歉,没有安装 html 文件的格式化程序
任何的想法?
VS 代码版本 1.19.1
// Enable/disable autoclosing of HTML tags.
"html.autoClosingTags": true,
// List of tags, comma separated, where the content shouldn't be reformatted. 'null' defaults to the 'pre' tag.
"html.format.contentUnformatted": "pre,code,textarea",
// Enable/disable default HTML formatter
"html.format.enable": true,
// End with a newline.
"html.format.endWithNewline": false,
// List of tags, comma separated, that should have an extra newline before them. 'null' defaults to "head, body, /html".
"html.format.extraLiners": "head, body, /html",
// Format and indent {{#foo}} and …Run Code Online (Sandbox Code Playgroud) 前提:当我使用 Visual Studio Code 时,我想在保存时检查 linting,我喜欢智能感知。
尽管如此,当我输入. 它们绝对没用(我从不看它们),分散注意力,屏幕底部出现和消失所有华丽的东西,昨天,当我的电脑由于其他原因已经变慢时,它使打字变得缓慢。
由于我找不到在打字时禁用 linting 的方法,我进入了设置并禁用了大部分打字稿控件(因为它们是最严重的罪犯,对我来说没用,因为我很少使用 .ts,无论如何我使用flow+jshint,已经绰绰有余了)。而且,出于一些神奇的原因,它甚至似乎在打字时禁用了 linting,只在保存时保持活动状态。
但是今天,当我打开 VSCode 时,打字时的 linting 重新启动。[ts] 错误现在很少了,但是 jshint 仍然会产生一些错误。幸运的是,Flow 可以按预期工作,并且只能在保存时使用。
那么,有没有办法在打字时禁用 linting,让智能感知、代码完成建议和保存时的 linting 保持活动状态?
编辑:我启用了以下扩展:HTML CSS Support 0.2.0、html to javascript string 0.0.6、JavaScript Booster 0.10.2、jshint 0.10.20、Sorting HTML and Jade attributes 2.1.0、Todo Tree 0.0.116、 vscode-流-ide 1.2.0
(暂时我禁用了智能感知,看看它是否解决了问题。它没有)
在 TypeScript 中,我定义了一个名为的辅助函数create,它接受一个构造函数和构造函数的类型参数来创建一个类的新实例:
function create<Ctor extends new (...args: any[]) => any, R extends InstanceType<Ctor>>(
ctor: Ctor,
...args: ConstructorParameters<Ctor>
): R {
return new ctor(...args)
}
Run Code Online (Sandbox Code Playgroud)
这适用于像这样的简单类:
class Bar {
constructor(param: number) { }
}
const bar1 = create<typeof Bar, Bar>(Bar, 1);
// Compile error: Argument of type '"string"' is not assignable to parameter of type 'number'.ts(2345)
const bar2 = create<typeof Bar, Bar>(Bar, 'string');
Run Code Online (Sandbox Code Playgroud)
但是,如果我有一个泛型类,则无法让 TypeScript 对以下内容执行正确的类型检查create:
class Foo<T> {
constructor(param: T) { }
}
// Ok …Run Code Online (Sandbox Code Playgroud) typescript ×3
algorithm ×1
css ×1
css3 ×1
html ×1
javascript ×1
jshint ×1
lint ×1
probability ×1
tsconfig ×1