- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我如何定义一个全局枚举以在定义的范围之外使用它?我创建了一个导入另一个脚本的脚本(包括所有全局函数、变量和枚举)
Enum CrudFlag
{
Undefined
Create
Read
Update
Delete
}
最佳答案
您必须使用dotsourceing 导入您的脚本:
Each script runs in its own scope. The functions, variables, aliases, and drives that are created in the script exist only in the script scope. You cannot access these items or their values in the scope in which the script runs.
To run a script in a different scope, you can specify a scope, such as Global or Local, or you can dot source the script.
The dot sourcing feature lets you run a script in the current scope instead of in the script scope. When you run a script that is dot sourced, the commands in the script run as though you had typed them at the command prompt. The functions, variables, aliases, and drives that the script creates are created in the scope in which you are working. After the script runs, you can use the created items and access their values in your session.
To dot source a script, type a dot (.) and a space before the script path
关于powershell - 使用另一个脚本中定义的枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39719297/
我是一名优秀的程序员,十分优秀!