[英]JavaScript namespace references in IntelliSense
I'm learning how to put all my JS inside a namespace and how add other things to the same namespace. 我正在学习如何将我的所有JS放在一个名称空间中,以及如何将其他内容添加到同一名称空间中。 I'm using VS 2013 with a MVC page.
我正在使用带有MVC页面的VS 2013。
Here I create skillet
in first namespace.js
with some properties, then in namespace2.js
add another property. 在这里,我首先在带有一些属性的
namespace.js
创建skillet
,然后在namespace2.js
添加另一个属性。
As you can see in HTML after adding both JS I can see all properties. 正如您在添加两个JS后在HTML中看到的那样,我可以看到所有属性。 But inside
namespace2.js
cant see properties from namespace.js
但是在
namespace2.js
内部看不到来自namespace.js
属性
My idea is have a main JS for all my projects, and use the second one to fine details depending on specifics requirements. 我的想法是为我的所有项目都拥有一个主要的JS,并根据具体要求使用第二个JS来细化细节。
Is there a way second JS know what is define in first JS? 有没有办法让第二个JS知道第一个JS中的定义?
Something like: 就像是:
#include "namespace.js"
using namespace.js;
<script>namespace.js</script>
you could use /// <reference ...>
directive as you can see in msdn docs 您可以使用
/// <reference ...>
指令,如msdn文档中所见
Other useful answers in SO: SO中的其他有用答案:
Best Practices for IntelliSense JavaScript references IntelliSense JavaScript参考的最佳做法
Enabling javascript intellisense for external libraries in Visual Studio 在Visual Studio中为外部库启用javascript intellisense
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.