優零零
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- type: slide --- # swiper套件 ###### tags:`HyUI4.0` --- HyUI 4.0 改使用 swiper 作為輪播的套件 目前使用的版本為 8.4.4 swiper功能也是蠻豐富的,可以自訂的內容也不少 且有中文的API使用參考網站 英文版網站:[https://swiperjs.com/](https://swiperjs.com/) 中文版網站:[https://www.swiper.com.cn/](https://www.swiper.com.cn/) (中文的api有些是舊的,使用上要注意) 詳細解釋每一個參數:[https://developer.aliyun.com/article/272546](https://developer.aliyun.com/article/272546) (版本較早,但可以參考) --- swiper 相較 slick 使用上會稍微複雜一些,且部分class是無法變更名稱的 html結構 ```html= <!-- swiper 區塊 --> <div class="swiper"> <!-- 輪播內容區塊class不可變更 --> <div class="swiper-wrapper"> <!-- 輪播項目class不可變更 --> <div class="swiper-slide" data-title="內容 1">內容 1</div> <div class="swiper-slide" data-title="內容 2">內容 2</div> <div class="swiper-slide" data-title="內容 3">內容 3</div> ... </div> <!-- 若需要切換點,需自行增加此div --> <div class="swiper-pagination"></div> <!-- 若需要左右切換,需自行增加此div --> <button class="swiper-button-prev"></button> <button class="swiper-button-next"></button> <!-- 若需要卷軸,需自行增加此div --> <div class="swiper-scrollbar"></div> </div> ``` --- js語法 ```javascript= let mpSliderItem = document.querySelectorAll('.mpSlider .swiper-slide'); let mpSliderPagination = []; mpSliderItem.forEach((item, index) => { mpSliderPagination.push(item.dataset.title); }); const swiper = new Swiper('.swiper', { slidesPerView: 1, //顯示筆數 spaceBetween: 20, //每筆之間的距離 navigation: { nextEl: '.bannerSlider .nextSlider', //下一筆class,無障礙設定關係需要增加.nextSlider prevEl: '.bannerSlider .prevSlider', //前一筆class,無障礙設定關係需要增加.prevSlider disabledClass: 'swiperArrow-disabled', //不可點選樣式 }, pagination: { //顯示圓點 el: '.swiperDots', //圓點 class type: 'bullets', //樣式參考 https://www.swiper.com.cn/api/pagination/299.html clickable: true, //設定後圓點才可以點擊 renderBullet: function (index, className) { return `<button class="${className} noFonts" aria-label="${mpSliderPagination[index]}">${mpSliderPagination[index]}</button>`; }, }, autoplay: { //自動播放 delay: 5000, //自動播放的間隔 }, loop: true, //無限輪播 effect: 'fade', //淡入 fadeEffect: { crossFade: true, //上一筆淡出,false上一筆不淡出,下一筆疊在上方 }, }); ``` --- pagination圓點切換無障礙相關 如果有需要使用圓點且要有無礙的話 1.html .swiper-slide 增加 data-title="文字" 2.加入以下程式碼,要寫在swiper前面 ```javascript= // 變數每個swiper都要不一樣 //mpSliderItem 指定該swiper元件中的 .swiper-slide let mpSliderItem = document.querySelectorAll('.mpSlider .swiper-slide'); let mpSliderPagination = []; mpSliderItem.forEach((item, index) => { mpSliderPagination.push(item.dataset.title); }); ``` 3.swiper的js內 pagination 增加,變數要對應上面設定的變數 ```javascript= renderBullet: function (index, className) { return `<button class="${className} noFonts" aria-label="${mpSliderPagination[index]}">${mpSliderPagination[index]}</button>`; } ``` --- 左右切換鍵無障礙相關 swiper其實有地方可以設定文字,不同語系要個別設定,所以另外寫語系功能 在main.js最下方有設定箭頭文字的功能 ```javascript= swiperArrows({ next: '.nextSlider', prev: '.prevSlider', data: [ //增加語系請寫在這邊 { lang: 'zh', nextText: '下一筆', prevText: '上一筆', }, //...由此新增其他語系 ], //預設語系 default: { nextText: 'next', prevText: 'previous', }, }); ``` <style> .reveal h1{ font-size:2em; } .reveal h1,.reveal h2 { color:#c9f2ff; } .reveal{ font-size:26px; } </style>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully