30 lines
515 B
Vue
30 lines
515 B
Vue
<template>
|
|
<button class="but" @click="handleClick">{{ text }}</button>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
// 1. 定义接收父组件传来的参数 props
|
|
const props = defineProps({
|
|
// 字段名、类型、默认值
|
|
text: String,
|
|
})
|
|
|
|
const emit = defineEmits(['click'])
|
|
// 定义 click 事件
|
|
const handleClick = (): any => {
|
|
emit('click')
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
.but {
|
|
text-decoration: underline;
|
|
color: #1e5494;
|
|
font-size: 18px;
|
|
cursor: pointer;
|
|
background: none;
|
|
border: none;
|
|
}
|
|
</style>
|