vue帮我设计一个好看并且居中的按钮最好是蓝色
时间: 2024-02-26 16:58:04 浏览: 22
好的,以下是一个简单的 Vue 组件代码示例,实现了一个蓝色的居中按钮:
```html
<template>
<button class="blue-button">{{ label }}</button>
</template>
<script>
export default {
props: {
label: {
type: String,
required: true
}
}
}
</script>
<style scoped>
.blue-button {
background-color: #2196f3;
color: white;
border: none;
border-radius: 4px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
display: block;
margin: 0 auto;
}
</style>
```
你只需要在父组件中使用这个组件,并传递一个 `label` 属性即可:
```html
<template>
<div>
<blue-button label="点击我"></blue-button>
</div>
</template>
<script>
import BlueButton from '@/components/BlueButton.vue'
export default {
components: {
BlueButton
}
}
</script>
```
这样就可以在页面上看到一个居中蓝色的按钮了。