Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-04-21 18:04:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1d2314d3a6a0a277c59bc45b6b7e676f4dc68c90
1d2314d3
1 parent
95a3bc9f
✨ feat(组件): 按钮组件新增自定义样式和点击回调
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
src/components/MyButton/index.vue
src/components/MyButton/index.vue
View file @
1d2314d
<template>
<div v-if="type === 'primary'" class="button-primary">
<div v-if="type === 'primary'" class="button-primary"
@click="handle"
>
<slot></slot>
</div>
<div v-if="type === 'plain'" class="button-plain">
<div v-if="type === 'plain'" class="button-plain" @click="handle">
<slot></slot>
</div>
<div v-if="type === 'custom'" :style="customStyle" class="button-custom" @click="handle">
<slot></slot>
</div>
</template>
...
...
@@ -10,9 +13,13 @@
<script setup>
import
{
ref,
reactive,
onMounted
}
from
'vue'
const
props
=
defineProps
({
type: String
type:
String,
customStyle:
Object
})
const
emit
=
defineEmits
([
'on-click'
]);
const
handle
=
()
=
>
{
emit
(
'on-click'
,
''
)
}
onMounted
(()
=
>
{
})
...
...
@@ -35,6 +42,7 @@ export default {
</script>
<style lang="less" scoped>
@base
:
#F9D95C;
.
button-primary
{
width:
auto
;
height:
auto
;
...
...
@@ -42,9 +50,9 @@ export default {
padding:
0.6
rem
;
margin:
0.5
rem
;
font-size:
1
rem
;
background:
#F9D95C
;
background:
@base
;
border-radius:
24
px
;
border: 1px solid
#F9D95C
;
border:
1
px
solid
@base
;
color:
#0B3A72;
}
.
button-plain
{
...
...
@@ -59,4 +67,13 @@ export default {
border:
1
px
solid
#0B3A72;
color:
#0B3A72;
}
.
button-custom
{
width:
auto
;
height:
auto
;
text-align:
center
;
padding:
0.6
rem
;
font-size:
1
rem
;
border-radius:
24
px
;
border:
1
px
solid
;
}
</style>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment