Visual Studio Code 中的 JQuery 智能感知 [英] JQuery intellisense in Visual Studio Code

查看:31
本文介绍了Visual Studio Code 中的 JQuery 智能感知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定使用 Visual Studio Code 来创建应用程序.
现在我似乎无法让智能感知同时为 JQuery 和 JQuery Mobile 工作.

我的 VSC 版本是 0.10.1

我尝试添加包含此内容的 reference.d.ts 文件

///<reference path="js/jquery.d.ts"/>///<参考路径="js/jquerymobile.d.ts"/>

(从

有关更多信息,请查看官方文档

I decided to jump in Visual Studio Code to create an app.
Now I can't seem to get intellisense working for both JQuery and JQuery Mobile.

My VSC version is 0.10.1

I tried adding a reference.d.ts file with this contents

/// <reference path="js/jquery.d.ts"/>
/// <reference path="js/jquerymobile.d.ts"/>

(files downloaded from https://github.com/DefinitelyTyped/DefinitelyTyped)

I tried opening a .js file, add a $(this) and hitting ctrl+period but it says 'No suggestions'.

Something I missed?

UPDATE:

Tried adding a jsconfig.json file following https://code.visualstudio.com/docs/languages/javascript#_javascript-projects-jsconfigjson

{
    "files": [
        "js/jquery.d.ts",
        "js/jquerymobile.d.ts"
    ]
}

Restarted, nothing...

UPDATE 2:

added a .js file, typed $ and clicked on the lightbulb to download jquery.d.ts file. It warns me about adding this file to the jsconfig.json file. After doing all this, restarted still not working.

jsconfig.json file contents:

{
    "files": [
        "typings/jquery/jquery.d.ts"
    ]
}

Nothing!

解决方案

Latest (as of April 2017) suggested approach to do this is to use automatic type acquisition by adding jsconfig.json file in the root of your project with the following contents:

{
 "typeAcquisition": {
     "include": [
         "jquery"
     ]
   }
}

Then, in your editor you will see:

For more information, check official documentation

这篇关于Visual Studio Code 中的 JQuery 智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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