Piman
  • Piman 無障礙網頁前端 UI 框架
  • 關於 Piman
  • 常見問答
  • Vue3 版本
    • 設計系統
  • Vue2 版本
    • 設計系統
    • 快速開始
    • Accordion
    • Breadcrumb
    • Buttons
    • Cards
    • Checkbox
    • Dialog
    • Dropdown
    • Form
    • Input
    • Message
    • Pagination
    • Popover
    • Radio
    • Select
    • Switch
    • Tabs
    • Tooltip
    • Tree
  • 更新日誌
  • 成為貢獻者,一起開發 Piman
    • Vue2
      • i18n
      • CSS & SCSS
      • Update
      • Develope Component
Powered by GitBook
On this page
  • 開新檔案
  • 註冊
  • Type
  • 如果想快速在 Nuxt2 開發時測試…

Was this helpful?

Export as PDF
  1. 成為貢獻者,一起開發 Piman
  2. Vue2

Develope Component

PreviousUpdate

Last updated 1 year ago

Was this helpful?

Give someone a program, you frustrate them for a day; teach them how to program, you frustrate them for a lifetime.

—— David Leinweber

開發元件是如此的有趣、有意義,以至於開發者會無時無刻在腦海裡邊寫程式,只為了好用。

開新檔案

  1. 在 src/components 建立 .vue 檔。

  2. naming style:Camel Case,以 ‘Bpa’開頭,例如: BpaButton.vue

註冊

// src/components/index.ts

import BpaButton from "./BpaButton.vue";

const Components: {[key: string]: any} = {
  BpaButton,
  //...
}

然後在 .vue 檔使用。

Type

在 /type 資料夾內新增 newFileName}.d.ts 檔案, 然後在 /types/bpa.d.ts 裡註冊

// types/bpa.d.ts

// import
import { BpaNewComponent } from './new-component'

// export
/** NewComponent Component */
export class NewComponent extends BpaNewComponent {}

如果想快速在 Nuxt2 開發時測試…

  1. npm run build

  2. 複製 /dist 資料夾內容到 Nuxt

  3. import piman from “your-path/piman.umd.js

  4. npm run dev

一台螢幕發出藍、紅、黃、粉、紫色的筆記型電腦