2024-Vue/C1-基础语法/03.响应式-选项式.html

36 lines
762 B
HTML
Raw Normal View History

2024-11-27 08:46:34 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- 1. 导入vue.js的脚本文件 -->
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<button @click="increment">增加</button>
<p>{{count}}</p>
</div>
</body>
<script>
const vm = {
data: function () {
// const count = Vue.ref(0);
return {
count: 1
}
},
methods: {
increment() {
this.count++;
}
}
}
const app = Vue.createApp(vm);
app.mount('#app')
</script>
</html>