jquery を .js ファイルにインポートする方法を知りたいです。コードヒント (intellinse) を使用できるようにしたいのですが、これが別のファイルであるため、それを行うことはできません。インポートする必要はないかもしれませんが、取得する方法はありますか
$().[hint]
スタンドアロンの .js ファイル内に表示するには?
jquery を .js ファイルにインポートする方法を知りたいです。コードヒント (intellinse) を使用できるようにしたいのですが、これが別のファイルであるため、それを行うことはできません。インポートする必要はないかもしれませんが、取得する方法はありますか
$().[hint]
スタンドアロンの .js ファイル内に表示するには?
これをjsファイルの先頭に置きます
/// <reference path="/js/jquery.js" />
これは、JavaScriptのインテリセンスに関するMicrosoftのページです:http://msdn.microsoft.com/en-us/library/bb385682.aspx
私はそれらのフォーマットを使用しました、そしてそれは一般的にうまくいきます。jQueryには、スクリプトディレクトリに配置するエクスポート(jquery- [version] -vsdoc.jsなど)があります。
次に、スクリプトの先頭に追加する///<reference path="path/to/jquery-[version].js" />
と、すべてが機能しているように見えます(ほとんどの場合)。
スキーマに関するドキュメントは非常に限られていますが、スキーマがどのように見えるかについての大まかなXSDを作成しました(VSはサポートしていると主張するすべてのものをピックアップしているわけではありません)
編集:VS2010用のSP1をインストールする場合は、JSインテリセンスの最新のサポートを取得する必要があります。そうでない場合、マイクロソフトはそれをサポートするための拡張機能を持っています。上記の-vsdoc.jsファイルを取得するには、nugetを使用して取得するのが最も簡単な方法です。
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Schema is based on http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx -->
<!-- para tags are not specced on that page but are included as part of the VS JScript Editor Extensions -->
<!-- The "End" tag is a wrapper tag so I can make a valid document -->
<xs:element name="End">
<xs:complexType>
<xs:choice>
<xs:element name="reference" minOccurs="0" maxOccurs="unbounded" type="referenceType"/>
<xs:sequence>
<xs:element name="summary" type="TextContent"/>
<xs:element name="param" minOccurs="0" maxOccurs="unbounded" type="ParamNamedTypedTextContent" />
<xs:element name="field" minOccurs="0" maxOccurs="unbounded" type="NamedTypedTextContent" />
<xs:element name="returns" minOccurs="0" maxOccurs="1" type="TypedTextContent" />
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:complexType name="referenceType">
<xs:attribute name="path" type="xs:string" use="required" />
<xs:attribute name="assembly" type="xs:string" use="optional" />
<xs:attribute name="name" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="TextContent" mixed="true">
<xs:sequence>
<xs:element name="para" minOccurs="0" maxOccurs="unbounded" type="xs:string" />
</xs:sequence>
<xs:attribute name="locid" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="TypedTextContent">
<xs:complexContent>
<xs:extension base="TextContent">
<xs:attribute name="type" type="xs:string" use="optional" />
<xs:attribute name="elementType" type="xs:string" use="optional" />
<xs:attribute name="integer" type="xs:boolean" use="optional" />
<xs:attribute name="mayBeNull" type="xs:boolean" use="optional" />
<xs:attribute name="domElement" type="xs:boolean" use="optional" />
<xs:attribute name="elementInteger" type="xs:boolean" use="optional" />
<xs:attribute name="elementDomElement" type="xs:boolean" use="optional" />
<xs:attribute name="elementMayBeNull" type="xs:boolean" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="NamedTypedTextContent">
<xs:complexContent>
<xs:extension base="TypedTextContent">
<xs:attribute name="name" type="xs:string" use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="ParamNamedTypedTextContent">
<xs:complexContent>
<xs:extension base="NamedTypedTextContent">
<xs:attribute name="optional" type="xs:boolean" use="optional" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
EDIT2:VSインテリセンスでサポートされているタグを使用して記述されたコードの例を次に示します。
function getDottedProperty(obj, dottedPropertyChain) {
///<summary>
/// <para>
/// Returns the property of the object given by the dotted property
/// chain.
/// </para>
/// <para>
/// Example:
/// GetDottedProperty(
/// { a: { b: { c: { d: 'hello' } } } },
/// 'a.b.c.d'
/// )
/// </para>
///</summary>
///<param name="obj" type="Object">Object</param>
///<param name="dottedPropertyChain" type="String">
/// The string of properties to access.
///</param>
var propertySplits = dottedPropertyChain.split('.');
while (propertySplits.length) {
obj = obj[propertySplits.shift()];
}
return obj;
}