-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
184 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,62 @@ | ||
<template> | ||
<div class="home"> | ||
<img alt="Vue logo" src="../assets/logo.png"> | ||
|
||
<div class="content">reactiveParams.test:{{ reactiveParams.test }}</div> | ||
|
||
<div class="content">test:{{ test }}</div> | ||
|
||
<div class="content">toRefsReactiveParams:{{ toRefTest }}</div> | ||
|
||
<button class="content" @click="changeReactiveParams">changeReactiveParams to 3</button> | ||
|
||
|
||
<section> | ||
<div>{{ objName }}</div> | ||
<button @click="handelClick">按钮</button> | ||
</section> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { reactive, toRefs, toRef } from 'vue' | ||
export default { | ||
name: 'Home', | ||
name: 'home', | ||
setup() { | ||
const reactiveParams = reactive({ | ||
test: 1, | ||
test2: 2 | ||
}) | ||
const toRefsReactiveParams = reactive({ | ||
toRefTest: 1, | ||
toRefTest2: 2 | ||
}) | ||
const changeReactiveParams = _ => { | ||
reactiveParams.test = 3 | ||
toRefsReactiveParams.toRefTest = 3 | ||
} | ||
console.log('reactiveParams', reactiveParams) | ||
console.log('toRefs reactiveParams', { ...toRefs(reactiveParams) }) | ||
console.log({...reactiveParams}) | ||
return { | ||
...reactiveParams, | ||
...toRefs(toRefsReactiveParams), | ||
reactiveParams, | ||
changeReactiveParams | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.content { | ||
margin: 10px 0 0; | ||
} | ||
</style> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<template> | ||
<div class="about"> | ||
<h1>This is an computed page</h1> | ||
|
||
<section class="section-input"> | ||
<span>FirstName:</span> | ||
<input type="text" v-model="firstName" /> | ||
</section> | ||
|
||
|
||
<section class="section-input"> | ||
<span>LastName:</span> | ||
<input type="text" v-model="lastName" /> | ||
</section> | ||
|
||
<section class="section-display"> | ||
fullName:{{ fullName }} | ||
</section> | ||
|
||
<section class="section-change"> | ||
<button @click="changeFullName">变化姓名</button> | ||
</section> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { computed, toRefs, reactive } from 'vue' | ||
export default { | ||
setup() { | ||
let state = reactive({ | ||
firstName: '', | ||
lastName: '', | ||
count: 0 | ||
}) | ||
let fullName = computed({ | ||
get: () => `${state.firstName} ${state.lastName}`, | ||
set: (value) => { | ||
console.log(value) | ||
let result = value.split(' ') | ||
state.firstName = result[0] | ||
state.lastName = result[1] | ||
} | ||
}) | ||
let changeFullName = _ => { | ||
fullName = 'john tan' | ||
} | ||
return { | ||
...toRefs(state), | ||
fullName, | ||
changeFullName | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<div class="home"> | ||
<img alt="Vue logo" src="../assets/logo.png"> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'lifeCycle', | ||
setup() { | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<div class="home"> | ||
<img alt="Vue logo" src="../assets/logo.png"> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'watch', | ||
}; | ||
</script> |