1. 程式人生 > 其它 >buUI- 一個Vue UI 元件

buUI- 一個Vue UI 元件

技術標籤:buUI- 一個Vue UI 元件vuejshtmljavascriptcss

buUI - 一個Vue UI 元件

作者:大補

安裝

使用本框架前,請在CSS中開啟 border-box

*{box-sizing: border-box;}

Button 元件

在這裡插入圖片描述
按鈕元件 Button.vue 單檔案元件。

<template>
    <button class="g-button">按鈕</button>
</template>

<script>
export default {};
</script>

<style lang="scss">
.g-button {
  font-size: var(--font-size);
  height: var(--button-height);
  padding: 0 1em;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: var(--button-bg);
  &:hover {
    border-color: var(--border-color-hover);
  }

  &:active {
    background-color: var(--button-active-bg);
  }

  &:focus {
    outline: none;
  }
}
</style>

新建一個app.js

import Vue from 'vue';
import Button from './button.vue';
Vue.component('g-button', Button) //全域性元件
new Vue({
    el: '#app',
})

新建一個index.html 引入 app.js 檔案

<!DOCTYPE html>
<html lang="zh-Hans">

<head>
    <meta charset="UTF-8">
    <meta name
="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title> </head> <style> * { margin: 0; padding: 0; box-sizing: border-box; } :root { --button-height: 32px; --font-size
: 14px; --button-bg: white; --button-active-bg: #eee; --border-radius: 4px; --color: #333; --border-color: #999; --border-color-hover: #666; }
</style> <style> #app { margin: 20px; } </style> <body> <div id="app"> <g-button></g-button> </div> </body> <script src="./src/app.js"></script> </html>