这是我的光滑滑块:
var informations_panel = document.querySelector("#block-views-block-wazne-informacje-strona-glowna-block-1 > div:nth-child(3) > div > div.view-content");
$(informations_panel).slick({
autoplay: true,
autoplaySpeed: 5000,
arrows: true,
dots: true,
infinite: true,
slidesToShow: 2,
slidesToScroll: 1
});
Run Code Online (Sandbox Code Playgroud)
当用户调整窗口大小时,有没有办法更改slidesToShow属性?使用 $(window).resize(),类似:
$(window).resize(function(){
var informations_panel = document.querySelector("#block-views-block-wazne-informacje-strona-glowna-block-1 > div:nth-child(3) > div > div.view-content");
if ($(window).width() < 992) {
$(informations_panel).slick({
autoplay: true,
autoplaySpeed: 5000,
arrows: true,
dots: true,
infinite: true,
slidesToShow: 1,
slidesToScroll: 1
});
}
});
Run Code Online (Sandbox Code Playgroud)
该解决方案出现错误,我无法再次在同一元素上初始化光滑。我只想slidesToShow当窗口宽度大于 992px 时将属性从 2 更改为 1。
我知道在 stackoverflow 上有很多与此错误类似的问题,但没有一个能解决我的问题。我的文件中有一个函数high_contrast.module:
function high_contrast_install() {
$background = \Drupal::config('high_contrast.settings')->get('colors_background');
$text = \Drupal::config('high_contrast.settings')->get('colors_text');
$hyperlinks = \Drupal::config('high_contrast.settings')->get('colors_hyperlinks');
\Drupal::service('file_system')->prepareDirectory(HIGH_CONTRAST_CSS_FOLDER, FileSystemInterface::CREATE_DIRECTORY); // LINE 17!!!
$css = _high_contrast_build_css();
file_save_data($css, HIGH_CONTRAST_CSS_LOCATION, FileSystemInterface::EXISTS_REPLACE);
}
Run Code Online (Sandbox Code Playgroud)
当我想安装该模块时,出现错误:
Error: Cannot pass parameter 1 by reference in high_contrast_install() (line 17 of modules\high_contrast\high_contrast.install).
Run Code Online (Sandbox Code Playgroud)
我该如何修复它?:(
第 17 行就是:
\Drupal::service('file_system')->prepareDirectory(HIGH_CONTRAST_CSS_FOLDER, FileSystemInterface::CREATE_DIRECTORY);
Run Code Online (Sandbox Code Playgroud)