parent
dd8a565b09
commit
aa3863b28a
4 changed files with 71 additions and 9 deletions
@ -0,0 +1,40 @@ |
|||||||
|
<template> |
||||||
|
<h1>个人信息:</h1> |
||||||
|
<h2>姓名:{{ name }}</h2> |
||||||
|
<h2>年龄:{{ age }}</h2> |
||||||
|
<h2>工作种类:{{ job.type }}</h2> |
||||||
|
<h2>薪水:{{ job.salary }}</h2> |
||||||
|
<button @click="changeInfo">修改信息</button> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import {ref} from "vue"; |
||||||
|
|
||||||
|
export default { |
||||||
|
name: 'App', |
||||||
|
setup() { |
||||||
|
// 数据 |
||||||
|
let name = ref('张三') |
||||||
|
let age = ref(19) |
||||||
|
let job = ref({ |
||||||
|
type: '前端工程师', |
||||||
|
salary: '30K' |
||||||
|
}) |
||||||
|
|
||||||
|
function changeInfo() { |
||||||
|
name.value = '李四' |
||||||
|
age.value = 88 |
||||||
|
job.value.type = '后端工程师' |
||||||
|
job.value.salary = '31K' |
||||||
|
console.log(name,age) |
||||||
|
} |
||||||
|
|
||||||
|
return { |
||||||
|
name, |
||||||
|
age, |
||||||
|
job, |
||||||
|
changeInfo, |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
After Width: | Height: | Size: 6.7 KiB |
@ -0,0 +1,10 @@ |
|||||||
|
// 引入的不再是Vue构造函数, 引入的是一个名为createApp的工厂函数
|
||||||
|
import { createApp } from 'vue' |
||||||
|
import App from './App.vue' |
||||||
|
|
||||||
|
// createApp(App).mount('#app')
|
||||||
|
|
||||||
|
// 创建应用实例对象
|
||||||
|
const app = createApp(App) |
||||||
|
console.log('@@@',app) |
||||||
|
app.mount('#app') |
Loading…
Reference in new issue