簡體   English   中英

Understrap WordPress入門主題

[英]Understrap wordpress starter theme

我想在我的未來主題中使用understrap,並想向其添加swiperjs庫,如腳本官方頁面所述,我必須從以下方法添加它:

npm install swiper

之后,我該怎么辦? 我必須從gulpfile.js中要求它嗎?

var swiper = require('swiper');
console.log(swiper) // output the swiper object from terminal after gulp scripts

在同一文件(gulpfile.js)中,我找到了一行,可以在其中添加自定義js:

    `${paths.dev}/js/skip-link-focus-fix.js`,

    // Adding currently empty javascript file to add on for your own themes´ customizations
    // Please add any customizations to this .js file only!
    `${paths.dev}js/custom-javascript.js`,

所以我在src文件夾中添加了帶有console.log('test')和alert('test')的'custom-javascript.js',最后運行了'gulp scripts && gulp watch'

我沒有得到console.log測試,也沒有得到警告。

有人可以幫我嗎?

==========已解決===============

因此,對於面臨相同問題的人,只需在js目錄前添加斜杠:

`${paths.dev}/js/custom-javascript.js` 

代替 :

`${paths.dev}js/custom-javascript.js`

謝謝

您可以從header.php文件中的CDN運行JS和CSS

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css">

並在footer.php文件中添加

<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM