最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Magento 2: $ is not a function - Stack Overflow

programmeradmin0浏览0评论

I added some js files in my custom theme using the file \app\design\frontend\<vendor>\<theme>\Magento_Theme\layout\default_head_blocks.xml

<link src="js/modernizr.custom.28468.js"/>
<link src="js/jquery.js"/>
<link src="js/bootstrap.min.js"/>
<link src="js/wow.js"/>
<link src="js/jquery.bxslider.js"/>
<link src="js/jquery_select.js"/>
<link src="js/page.js"/>

But it shows some errors in console, and functionality is not working properly

image

Any help will be appreciated.

I added some js files in my custom theme using the file \app\design\frontend\<vendor>\<theme>\Magento_Theme\layout\default_head_blocks.xml

<link src="js/modernizr.custom.28468.js"/>
<link src="js/jquery.js"/>
<link src="js/bootstrap.min.js"/>
<link src="js/wow.js"/>
<link src="js/jquery.bxslider.js"/>
<link src="js/jquery_select.js"/>
<link src="js/page.js"/>

But it shows some errors in console, and functionality is not working properly

image

Any help will be appreciated.

Share Improve this question edited Aug 9, 2016 at 13:02 VIPIN A ROY 1,7815 gold badges29 silver badges43 bronze badges asked Aug 3, 2016 at 12:20 Hima MohanHima Mohan 1211 silver badge4 bronze badges 2
  • I'd hazard a guess that modernizr...js is probably dependent on jQuery. Thus jQuery must be referenced before it- I'm sure there's a duplicate, but I can't find a good one. Also using <link> for JS is an odd practice, <script> is more conventional: stackoverflow./questions/13739568/… – HPierce Commented Aug 3, 2016 at 12:58
  • @HPierce Thanks for your reply. I have changed link to script and give order to jquery.js and modernizer..js. But still it is not working. – Hima Mohan Commented Aug 4, 2016 at 5:08
Add a ment  | 

1 Answer 1

Reset to default 5

This is because of some jquery conflicts in the js files you used. Please add the below code in your first line of page.js

var $ = jQuery.noConflict();
发布评论

评论列表(0)

  1. 暂无评论