小编Zer*_*umi的帖子

打字稿:不能在模块外使用导入语句

我在 node js(07.10.19 的最新版本 node.js)应用程序中有一个 .ts 文件,它导入了没有默认导出的节点模块。我使用这种结构:import { Class } from 'abc';当我运行代码时,我有这个错误:Cannot use import statement outside a module

在网络中,我看到了许多针对此问题的解决方案(针对 .js),但对我没有帮助,可能是因为我有打字稿文件。这是我的代码:

import { Class } from 'abc';
module.exports = { ...
    execute(a : Class ,args : Array<string>){ ...
Run Code Online (Sandbox Code Playgroud)

这是我的 tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",

    "strict": true
  }
}
Run Code Online (Sandbox Code Playgroud)

typescript ecmascript-6

67
推荐指数
5
解决办法
11万
查看次数

C# WPF OnMouseEnter 和 OnMouseLeave 循环

我有 WPF UI 元素,当鼠标光标进入此元素时,这些元素应该隐藏,当鼠标光标离开此元素时,这些元素应该可见。为此,我使用 events OnMouseEnter& OnMouseLeave,如下所示:

private void TextBlock_MouseEnter(object sender, MouseEventArgs e)
{
    (e.Source as UIElement).Visibility = Visibility.Hidden;
}

private void TextBlock_MouseLeave(object sender, MouseEventArgs e)
{
    (e.Source as UIElement).Visibility = Visibility.Visible;
}
Run Code Online (Sandbox Code Playgroud)

(以下代码来自https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.panel.zindex?view=netframework-4.8

<Canvas>
            <Rectangle Canvas.ZIndex="1" Width="100" Height="100" Canvas.Top="100" Canvas.Left="100" Fill="blue" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave"/>
            <Rectangle Canvas.ZIndex="2" Width="100" Height="100" Canvas.Top="150" Canvas.Left="150" Fill="yellow" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave"/>
            <Rectangle Canvas.ZIndex="3" Width="100" Height="100" Canvas.Top="200" Canvas.Left="200" Fill="green" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave"/>

            <!-- Reverse the order to illustrate z-index property -->

            <Rectangle Canvas.ZIndex="3" Width="100" Height="100" Canvas.Top="300" …
Run Code Online (Sandbox Code Playgroud)

c# wpf

3
推荐指数
1
解决办法
554
查看次数

标签 统计

c# ×1

ecmascript-6 ×1

typescript ×1

wpf ×1