IntelliSense JavaScript参考的最佳实践 [英] Best Practices for IntelliSense JavaScript references

查看:97
本文介绍了IntelliSense JavaScript参考的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有人为JavaScript Intellisense正确设置了Visual Studio 2008,那么实际的javascript引用声明的最佳做法是什么?

Assuming a person has Visual Studio 2008 set up correctly for JavaScript Intellisense, what are the best practices for the actual javascript reference declarations?

基本形式,当然,是(在文件的顶部):

The basic form, of course, is (right up at the top of the file):

///<reference path="path-to-file.js" />

但该路径有哪些规则?

Webapps

网络应用程序是否应该像网址一样使用正斜杠? filename.js用于同一目录中的文件? ./filename.js?根相对/path/to/filename.js?所有这些都应该有效吗?像../../filename.js这样的相对路径是否有效?

Should web applications use forward slashes like a url? "filename.js" for files in the same directory? "./filename.js"? Root relative "/path/to/filename.js"? Are all of these supposed to work? Do relative paths like "../../filename.js" work?

类库

在构建嵌入式资源.js文件的类库时怎么样?它们应该像Windows文件路径一样使用反斜杠吗?转义为.NET字符串文字中的双反斜杠?

What about when building class libraries of embedded resource .js files? Should these use backslashes like a Windows file path? Escaped double backslashes like in a .NET string literal?

当webapp中的.js文件引用类库中的文件时,该怎么办?在开发插件时通常会出现这种情况 - 您有一组现有插件,并且您在Web上下文中开发了一个新插件,因此您不必继续重建类库,然后在完成后你将它移动到类库中。你会怎么引用它?完全C:\ long \path\to\project\directory\file.js?

What about when a .js file in a webapp references one in a class library? This could commonly be the case during development of a plugin - you have a set of existing plugins, and you develop a new one in a web context so you don't have to keep rebuilding the class library, and then when you're done you move it into the class library. How would you reference that? By full "C:\long\path\to\project\directory\file.js"?

级联依赖性

如果A.js引用引用引用D.js的C.js的B.js,来自不同目录的怎么办?

What about if A.js references B.js which references C.js which references D.js, all from different directories?

A.js是否应包含对B,C和D的引用,或者引用是否应该级联到A.js?

Should A.js contain references to B, C, and D, or should the references cascade to A.js?

更多??

我将启用社区Wiki,以便希望这可以成为最佳实践的汇编。

I'll enable the Community Wiki so that hopefully this can become a compendium of best practices.

推荐答案

查看这两个博客条目。他们应该回答你的大部分问题:

Check out these two blog entries. They should answer most of your questions:

http://blogs.msdn.com/webdevtools/archive/2008/11/18/jscript-intellisense-faq.aspx

http://blogs.msdn.com/webdevtools/archive/2007/03/02/jscript-intellisense-in-orcas.aspx

这篇关于IntelliSense JavaScript参考的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆