这是代码冲突吗? [英] Is it a code conflict?

查看:50
本文介绍了这是代码冲突吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我网站上安装的主脚本包含:

Master script installed on my website contains:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"/>
    
<script src="https://apis.google.com/js/plusone.js" type="text/javascript">
    {lang: "en-US"}
    </scr ipt>



编辑:我已经拆分了关闭脚本标签,因为它似乎触发了网站上的一个错误。)



当我尝试添加另一个元素时以下脚本,它拒绝显示任何回复 -


( I've split the closing script tag, as it seems to have triggered a bug on the site.)

When I try to add another element with following script, it refuses to show up any responce -

<script type="text/javascript" src="http://project.dimpost.com/flexslider-carousel/jquery.js"></script>

    <script type="text/javascript" src="http://project.dimpost.com/flexslider-carousel/jquery.flexslider-min.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {
        $(window).load(function() {
            $('.flexslider').flexslider({
               
            });
        });
    });
    </script>



可能是什么问题以及如何解决这个问题?



我的尝试:



已添加 $。noConflict()喜欢这样并尝试:


What could be the issue and how to resolve that?

What I have tried:

Added $.noConflict() like this and tried:

<script type="text/javascript">
$.noConflict();
$(document).ready(function() {
    $(window).load(function() {
        $('.flexslider').flexslider({
            
        });
    });
});
</script>








编辑:从解决方案1中添加:



但是这个代码在没有任何jquery脚本运行的平台上运行没有任何问题。如果已经存在冲突问题。 java控制台显示以下两个错误:



1.TypeError:$不是函数



2.不推荐使用getPreventDefault()。改为使用defaultPrevented。



如何解决这两个错误?





Added from solution 1:

But this code is working without any problem on a platform without any jquery script already running. If there is already one, conflict issues. The java console shows the following two errors:

1.TypeError: $ is not a function

2.Use of getPreventDefault() is deprecated. Use defaultPrevented instead.

How to dela with these two errors?

推荐答案

document )。ready( function (){
(document).ready(function() {


window )。load( function (){
(window).load(function() {


' 。flexslider')。flexslider({

});
});
});
< / script >
('.flexslider').flexslider({ }); }); }); </script>



可能是什么问题以及如何解决这个问题?



我尝试过:



已添加


What could be the issue and how to resolve that?

What I have tried:

Added


这篇关于这是代码冲突吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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