Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fe5e32b8e |
+57
-7
@@ -1,11 +1,61 @@
|
|||||||
<script setup lang="ts"></script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1>You did it!</h1>
|
<p>姓名:<input v-model="name" /> {{ name }}</p>
|
||||||
<p>
|
<p>薪水:<input v-model="salary" /> {{ salary }}</p>
|
||||||
Visit <a href="https://vuejs.org/" target="_blank" rel="noopener">vuejs.org</a> to read the
|
<button @click="addSalary">涨工资</button> <br />
|
||||||
documentation
|
<button @click="deductSalary">扣工资</button>
|
||||||
</p>
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<p>学号:{{ student.id }}</p>
|
||||||
|
<p>成绩:{{ student.score }}</p>
|
||||||
|
<button @click="becomeGod">捞一下</button>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<p>姓名:{{ user.name }}</p>
|
||||||
|
<p>工作单位:<input v-model="user.department" />{{ user.department }}</p>
|
||||||
|
<button @click="investigate">调查</button>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
let name = ref("wkn")
|
||||||
|
let salary = ref(4000)
|
||||||
|
function addSalary(){
|
||||||
|
salary.value += 100
|
||||||
|
}
|
||||||
|
function deductSalary(){
|
||||||
|
salary.value -= 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
const student = reactive({
|
||||||
|
id:2405050505,
|
||||||
|
score:59
|
||||||
|
})
|
||||||
|
function becomeGod(){
|
||||||
|
if (student.score < 60){
|
||||||
|
student.score = 60
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
// ref不推荐包裹对象
|
||||||
|
const user = ref({
|
||||||
|
name:'wkn',
|
||||||
|
department:'江西省发改委'
|
||||||
|
})
|
||||||
|
function investigate(){
|
||||||
|
user.value.department = "落马"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
Reference in New Issue
Block a user