我在 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) 我有 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)
<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)