无法使enquire.js与drupal 8一起使用

问题描述 投票:0回答:1

我将在Drupal 8主题中使用此JS库。所以我在项目中添加了npm,然后在主题中添加了它:library.yml

at.enquire:
  remote: https://raw.githubusercontent.com/WickyNilliams/enquire.js
  version: "2.1.6"
  license:
    name: MIT
    url: https://raw.githubusercontent.com/WickyNilliams/enquire.js/master/LICENSE
    gpl-compatible: true
  js:
    https://cdnjs.cloudflare.com/ajax/libs/enquire.js/2.1.6/enquire.min.js: { type: external, minified: true }
  dependencies:
    - core/jquery
    - core/matchmedia

然后加载了vi amy info.yml:

<script src="https://cdnjs.cloudflare.com/ajax/libs/enquire.js/2.1.6/enquire.min.js"></script>

在我的js文件中:

$(document).ready(function () {
enquire.register("screen and (min-width:768px) and (max-width:1024px) and (orientation: landscape) and (min-resolution:1dppx)", {
      deferSetup : true,
        setup : function() {
        $(".acces_rubriques iframe").height('55vh').width('45vw');//Video Gde Taille HP
        },
      match : function() {
        console.log('Enquire.js : BP pour: tabletlandscape');
           //Video sur HP
      $(".acces_rubriques iframe").height('55vh').width('65vw');//Video Gde Taille HP
        },
        unmatch : function() {
            example.unmatch();
        }
    });//enquire.register(tabletlandscape)
  });//Fin document.ready

但是我的Android标签上什么也没发生。

可能缺少什么?谢谢

drupal-8 enquire.js
1个回答
0
投票

我知道在Drupal8上采用jquery v3捆绑包。但是我需要使用它来工作:

  jQuery( document ).ready(function() {
//Enquire stuff here
}

并通过以下方式将npm enquire.js加载到树枝模板中:

{{ attach_library('THEMENAME/npm.enquire') }}

以及通过THEMENAME.libraries.yml正确的JS:

npm.enquire:
  version: VERSION
  js:
    #Chargement des JS ajoutées via NPM ou externes
    node_modules/enquire.js/dist/enquire.min.js: {} 

所以它现在可以工作了。 :)

© www.soinside.com 2019 - 2024. All rights reserved.