根据 Vitest 文档,这应该允许在 Visual Studio 代码中调试 Vitest。所以我在 launch.json 中有以下内容:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
Run Code Online (Sandbox Code Playgroud)
它在调试器中运行,但所有断点都是“未绑定的”,因此是否有任何其他配置可以让您在断点处停止,以便您实际上可以在运行时检查代码?
以下代码从数据生成路径.
var path = gameBoard.append('path')
.attr("id", "snake" + snakeIndex)
.attr("d", interpolator(data))
.attr('stroke-width', snakeStroke)
.attr('fill', 'none')
.attr('stroke', config.snakeColor);
Run Code Online (Sandbox Code Playgroud)
数据定义的曲线路径正确绘制.
这里失败getTotalLength()没有定义:
var totalLength = path.getTotalLength();
Run Code Online (Sandbox Code Playgroud)
另外,getPointAlongLength()也未定义:
var point = path.getPointAtLength(position);
Run Code Online (Sandbox Code Playgroud) 以下代码工作,除了我尝试传递$gradient给@include background-image.
@mixin compositeFill($size: 100px, $gradient:(top, #000000 0%, #FFFFFF 100%)) {
$isTop: nth($gradient, 1) == "top";
$direction: if($isTop, vertical, horizontal);
$widthHeight: if($isTop, height, width);
$heightWidth: if($isTop, width, height);
// snipped a whole bunch of irrelevant stuff
// this is what fails:
@include background-image(linear-gradient($gradient));
}
Run Code Online (Sandbox Code Playgroud)
如何将列表(例如$gradient)传递给需要多个参数的mixin?
我有一个在 JavaScript 中工作的组件属性,但在 Typescript 中遇到问题:
props: {
keep_open: {
type: Array,
default: () => [],
}
}
Run Code Online (Sandbox Code Playgroud)
这个定义在这里并没有失败,而是在代码的后面:
let keepOpen: Array<string> = [this.data.popupId];
this.keep_open.forEach((id) => {
keepOpen.push(id);
});
Run Code Online (Sandbox Code Playgroud)
Keep_Open 中的 id 是未定义类型,不会推入 KeepOpen。
我该如何解决这个问题,无论是在后面的代码中还是在属性的定义中?
我在Visual Studio中使用了一个Minifier插件,除了这一段AngularJS代码外,该插件大部分都可以工作
这是未缩小的代码:
var svgBuildInterface = angular.module("svgBuildInterface", []);
svgBuildInterface.directive('ngRightClick', function ($parse) {
return function (scope, element, attrs) {
var fn = $parse(attrs.ngRightClick);
element.bind('contextmenu', function (event) {
scope.$apply(function () {
event.preventDefault();
fn(scope, { $event: event });
});
});
};
});
Run Code Online (Sandbox Code Playgroud)
这是打印精美的缩小的代码,但失败了:
svgBuildInterface = angular.module("svgBuildInterface", []);
svgBuildInterface.directive("ngRightClick", function(n) {
return function(t, i, r) {
var u = n(r.ngRightClick);
i.bind("contextmenu", function(n) {
t.$apply(function() {
n.preventDefault();
u(t, {
$event: n
})
})
})
}
});
Run Code Online (Sandbox Code Playgroud)
我无法在缩小的代码中添加断点以了解正在发生的事情,但是angularJS会引发异常:
Error: [$injector:unpr] http://errors.angularjs.org/1.5.7/
$injector/unpr?p0=nProvider%20%3C-%20n%20%3C-%20ngRightClickDirective
Run Code Online (Sandbox Code Playgroud)