
index.html
<!doctype html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
*{margin:0;padding: 0;box-sizing: border-box}
:root{
--button-height:32px;
--font-size:14px;
--font-size: white;
--border-radius:4px;
--button-active-bg:#eee;
--color:#333;
--border-color:#999;
--border-color-hover:#666;
--button-bg:white;
}
#app{
margin: 2px;
}
body{
font-size:var(--font-size)
}
</style>
<style>
</style>
<body>
<div id="app">
<g-button class="g-button"></g-button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="./src/app.js"></script>
<script>
new Vue({
el:'#app',
data:{
message:'hi'
}
})
</script>
</body>
</html>
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);
}
</style>
app.js
import Vue from 'vue'
import Button from "./button";
Vue.component('g-button',Button)
new Vue({
el:'#app'
})
浙公网安备 33010602011771号