【问题标题】:PhpStorm jQuery.noConflict() css completion not workingPhpStorm jQuery.noConflict() css 完成不起作用
【发布时间】:2017-11-12 03:44:47
【问题描述】:

$('#') // hint a list of id
var j = jQuery.noConflict()
j('#') // no hint
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

在 cmets 中使用上下文

【问题讨论】:

  • IDE 必须读取 jQuery 文件才能解析和理解它。下载并使用本地版本(开发首选非缩小版本)..或获取远程版本(在其上调用Alt+Enter)。 jetbrains.com/help/phpstorm/…
  • @LazyOne 我在一个空白的 HTML 页面中做了一个测试,一行 div#id-of-div,在
  • @LazyOne 这里是星期六,否则我会给出一些截图...
  • 我明白了。出于某种原因,我认为您在完成实际的 jQuery 方法时遇到了问题……而您的问题/问题是关于类/ids 的完成。很抱歉造成混乱。
  • @LazyOne 我的描述也不好,所以“不要摔倒道歉”:)

标签: jquery css phpstorm code-completion code-hinting


【解决方案1】:

我认为答案是模板/自动扩展,就像我有一个模板 $(' jj 的名称,所以 jj + tab 会给我我想要的...不是我打字慢,我只是更喜欢黑客我正在学习做一个懒惰的程序员

【讨论】:

    【解决方案2】:

    <!-- Putting jQuery into no-conflict mode. -->
    <script src="prototype.js"></script>
    <script src="jquery.js"></script>
    <script>
     
    var $j = jQuery.noConflict();
    // $j is now an alias to the jQuery function; creating the new alias is optional.
     
    $j(document).ready(function() {
        $j( "div" ).hide();
    });
     
    // The $ variable now has the prototype meaning, which is a shortcut for
    // document.getElementById(). mainDiv below is a DOM element, not a jQuery object.
    window.onload = function() {
        var mainDiv = $( "main" );
    }
     
    </script>

    【讨论】:

    • 谢谢你的回答,但我真正想要的是输入一个 j 而不是 shift 4
    猜你喜欢
    • 2021-08-12
    • 2016-10-30
    • 2011-11-15
    • 2021-03-16
    • 2017-06-10
    • 2015-01-30
    • 2021-05-04
    • 1970-01-01
    • 2012-03-03
    相关资源
    最近更新 更多