[英]TypeScript: the variable is defined on the MVC page
How can I make TypeScript aware that the Variable is defined in the cshtml file? 如何使TypeScript知道在cshtml文件中定义了变量? Can I add a reference inside the ts file?
我可以在ts文件中添加参考吗?
You can do this in a TypeScript file or a .d.ts file: 您可以在TypeScript文件或.d.ts文件中执行此操作:
declare var fromMvc: string;
This doesn't produce any code, but it makes the compiler aware that a variable with the name "fromMvc" exists. 这不会产生任何代码,但是会使编译器意识到存在名称为“ fromMvc”的变量。 After declaring that you can use it like a normal variable.
在声明可以像普通变量一样使用它之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.