撇号中不同版本的jquery冲突

时间:2018-06-14 06:35:52

标签: apostrophe-cms

我在我的项目中使用不同版本的jquery,撇号内置的jquery 3与jquery 1.12.4之间存在冲突,我正在使用它来进行旋转木马工作,冲突导致管理功能无法正常工作在撇号中,任何人都可以提供帮助。

3 个答案:

答案 0 :(得分:1)

降级到jQuery 1.x的正确方法是从项目级lib/modules/apostrophe-assets/index.js文件中删除此行:

jQuery: 3

但是,请记住,jQuery 2.x和3.x已经出现了好几年了,你应该尽可能地从任何过于陈旧的jQuery代码中迁移出来。

答案 1 :(得分:1)

To change the version of JQuery within Apostrophecms I have commented built-in JQuery version JQuery: 3 and then added updated version of jQuery through scripts.

that resolved JQuery conflict issue for me.Even though if extra JQuery Plugins also work with this solution if you want to add.

path: modules/apostrophe-assets/index.js

module.exports = {
  //jQuery: 3,
  scripts: [
    {
      name: 'modules/mytheme/js/jquery-3.1.1.min'
    }
  ]

};

My theme index file changes.

Path : modules/mytheme/index.js

module.exports = {
  construct: function(self, options) {
    // loads from public/css bootstrap modules
    self.pushAsset('stylesheet', 'bootstrap.min', { when: 'always' });
    self.pushAsset('stylesheet', 'animate.min', { when: 'always' });
    self.pushAsset('stylesheet', 'roboto-regular/styles.css', { when: 'always' });
    self.pushAsset('stylesheet', 'roboto-light/styles.css', { when: 'always' });
    self.pushAsset('stylesheet', 'font-awesome/css/font-awesome.min.css', { when: 'always' });
    self.pushAsset('stylesheet', 'site');

    // loads from public/js bootstrap modules
    self.pushAsset('script', 'popper', { when: 'always' });
    self.pushAsset('script', 'bootstrap.min', { when: 'always' });
    self.pushAsset('script', 'jquery.appear', { when: 'always' });
    self.pushAsset('script', 'jquery.matchHeight-min', { when: 'always' });
    self.pushAsset('script', 'functions', { when: 'always' });
    self.pushAsset('script', 'site', { when: 'always' });
  }
};

Hope this will help you.

答案 2 :(得分:0)

你试过jQuery Migrate吗?您使用哪种旋转木马?