@2alheure/vue-accordion 中文文档教程

发布于 3年前 浏览 22 项目主页 更新于 3年前

Vue JS Accordion

一个简单的 Vue JS 手风琴组件。
此组件与 Vue 3 兼容。

Installation

首先,运行 npm install @2alheure/vue-accordion
然后使用 import Accordion from "@2alheure/vue-accordion"; 导入它。

Usage

Simple usage example

<Accordion :headerStyle="headerStyle" :contentStyle="contentStyle">
  <template #header">
    Your accordion title. Can also be <strong>HTML</strong>.
  </template>

  Your accordion content. It can be simple text like this.
  <p>It can also be HTML.</p>
</Accordion>

<script>
  import Accordion from "@2alheure/vue-accordion";

  export default {
    components: {
      Accordion
    },
    data() {
      return {
        headerStyle: 'background-color: white;',
        contentStyle: {
          color: 'red',
          fontSize: '42px'
        }
      }
    }
  };
</script>

Props

NameTypeDefault valueDescription
openedBooleanfalseWhether the content should be displayed when loaded.
symbolOpenedString&or;The symbol to use for the opened accordion. (Can be HTML.)
symbolClosedString&gt;The symbol to use for the closed accordion. (Can be HTML.)
headerStyleString / Objectpadding: .5rem;The style for the header.
symbolStyleString / Objectfont-size: 1.5rem; font-weight: 700; vertical-align: middle;The style for the symbol.
contentStyleString / Objectwidth: 98%; margin: auto; padding: .5rem;The style for the content.
accordionClassString / ObjectnullThe classes for the accordion.
headerClassString / ObjectnullThe classes for the header.
symbolClassString / ObjectnullThe classes for the symbol.
contentClassString / ObjectnullThe classes for the content.

Events

NameDescription
openEmitted each time the accordion is opened.
closeEmitted each time the accordion is closed.
switchEmitted each time the accordion switches between open and close.

Vue JS Accordion

A simple Accordion component for Vue JS.
This component is compatible with Vue 3.

Installation

First, run npm install @2alheure/vue-accordion.
Then import it with import Accordion from "@2alheure/vue-accordion";.

Usage

Simple usage example

<Accordion :headerStyle="headerStyle" :contentStyle="contentStyle">
  <template #header">
    Your accordion title. Can also be <strong>HTML</strong>.
  </template>

  Your accordion content. It can be simple text like this.
  <p>It can also be HTML.</p>
</Accordion>

<script>
  import Accordion from "@2alheure/vue-accordion";

  export default {
    components: {
      Accordion
    },
    data() {
      return {
        headerStyle: 'background-color: white;',
        contentStyle: {
          color: 'red',
          fontSize: '42px'
        }
      }
    }
  };
</script>

Props

NameTypeDefault valueDescription
openedBooleanfalseWhether the content should be displayed when loaded.
symbolOpenedString&or;The symbol to use for the opened accordion. (Can be HTML.)
symbolClosedString&gt;The symbol to use for the closed accordion. (Can be HTML.)
headerStyleString / Objectpadding: .5rem;The style for the header.
symbolStyleString / Objectfont-size: 1.5rem; font-weight: 700; vertical-align: middle;The style for the symbol.
contentStyleString / Objectwidth: 98%; margin: auto; padding: .5rem;The style for the content.
accordionClassString / ObjectnullThe classes for the accordion.
headerClassString / ObjectnullThe classes for the header.
symbolClassString / ObjectnullThe classes for the symbol.
contentClassString / ObjectnullThe classes for the content.

Events

NameDescription
openEmitted each time the accordion is opened.
closeEmitted each time the accordion is closed.
switchEmitted each time the accordion switches between open and close.
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文