<template>
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<button @click="handleClick">点击我</button>
<p>{{ message }}</p> <!-- 显示 message 的内容 -->
</template>
<script>
import HelloWorld from './components/HelloWorld.vue';
import { ref } from 'vue';
export default {
name: 'App',
components: {
HelloWorld
},
setup() {
const message = ref('按钮未点击');
const handleClick = () => {
alert('按钮被点击了!');
message.value = '按钮已点击!'; // 更新 message 的值
};
return {
message,
handleClick
};
}
};
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>