Compare commits

..

No commits in common. 'main' and 'new_branch1' have entirely different histories.

  1. 23
      20_脚手架/vue3_test/.gitignore
  2. 26
      20_脚手架/vue3_test/1.src_分析Vue3结构/App.vue
  3. BIN
      20_脚手架/vue3_test/1.src_分析Vue3结构/assets/logo.png
  4. 58
      20_脚手架/vue3_test/1.src_分析Vue3结构/components/HelloWorld.vue
  5. 10
      20_脚手架/vue3_test/1.src_分析Vue3结构/main.js
  6. 13
      20_脚手架/vue3_test/10.src_watchEffect函数/App.vue
  7. BIN
      20_脚手架/vue3_test/10.src_watchEffect函数/assets/logo.png
  8. 54
      20_脚手架/vue3_test/10.src_watchEffect函数/components/demo.vue
  9. 10
      20_脚手架/vue3_test/10.src_watchEffect函数/main.js
  10. 22
      20_脚手架/vue3_test/11.src_vue3的生命周期/App.vue
  11. BIN
      20_脚手架/vue3_test/11.src_vue3的生命周期/assets/logo.png
  12. 76
      20_脚手架/vue3_test/11.src_vue3的生命周期/components/demo.vue
  13. 10
      20_脚手架/vue3_test/11.src_vue3的生命周期/main.js
  14. 22
      20_脚手架/vue3_test/12.src_自定义hook/App.vue
  15. BIN
      20_脚手架/vue3_test/12.src_自定义hook/assets/logo.png
  16. 26
      20_脚手架/vue3_test/12.src_自定义hook/components/demo.vue
  17. 24
      20_脚手架/vue3_test/12.src_自定义hook/hooks/usePoint.js
  18. 10
      20_脚手架/vue3_test/12.src_自定义hook/main.js
  19. 22
      20_脚手架/vue3_test/13.src_toRef和toRefs/App.vue
  20. BIN
      20_脚手架/vue3_test/13.src_toRef和toRefs/assets/logo.png
  21. 37
      20_脚手架/vue3_test/13.src_toRef和toRefs/components/demo.vue
  22. 10
      20_脚手架/vue3_test/13.src_toRef和toRefs/main.js
  23. 22
      20_脚手架/vue3_test/14.src_shallowReactive和shallowRef/App.vue
  24. BIN
      20_脚手架/vue3_test/14.src_shallowReactive和shallowRef/assets/logo.png
  25. 39
      20_脚手架/vue3_test/14.src_shallowReactive和shallowRef/components/demo.vue
  26. 10
      20_脚手架/vue3_test/14.src_shallowReactive和shallowRef/main.js
  27. 22
      20_脚手架/vue3_test/15.src_readonly与shallowReadonly/App.vue
  28. BIN
      20_脚手架/vue3_test/15.src_readonly与shallowReadonly/assets/logo.png
  29. 41
      20_脚手架/vue3_test/15.src_readonly与shallowReadonly/components/demo.vue
  30. 10
      20_脚手架/vue3_test/15.src_readonly与shallowReadonly/main.js
  31. 22
      20_脚手架/vue3_test/16.src_toRaw与markRaw/App.vue
  32. BIN
      20_脚手架/vue3_test/16.src_toRaw与markRaw/assets/logo.png
  33. 62
      20_脚手架/vue3_test/16.src_toRaw与markRaw/components/demo.vue
  34. 10
      20_脚手架/vue3_test/16.src_toRaw与markRaw/main.js
  35. 44
      20_脚手架/vue3_test/17.src_customRef/App.vue
  36. BIN
      20_脚手架/vue3_test/17.src_customRef/assets/logo.png
  37. 10
      20_脚手架/vue3_test/17.src_customRef/main.js
  38. 31
      20_脚手架/vue3_test/18.src_provide与inject/App.vue
  39. BIN
      20_脚手架/vue3_test/18.src_provide与inject/assets/logo.png
  40. 21
      20_脚手架/vue3_test/18.src_provide与inject/components/Child.vue
  41. 26
      20_脚手架/vue3_test/18.src_provide与inject/components/Son.vue
  42. 10
      20_脚手架/vue3_test/18.src_provide与inject/main.js
  43. 35
      20_脚手架/vue3_test/19.src_响应式的判断/App.vue
  44. BIN
      20_脚手架/vue3_test/19.src_响应式的判断/assets/logo.png
  45. 10
      20_脚手架/vue3_test/19.src_响应式的判断/main.js
  46. 28
      20_脚手架/vue3_test/2.src_初识Vue3的setup/App.vue
  47. BIN
      20_脚手架/vue3_test/2.src_初识Vue3的setup/assets/logo.png
  48. 10
      20_脚手架/vue3_test/2.src_初识Vue3的setup/main.js
  49. 23
      20_脚手架/vue3_test/20.src_Teleport/App.vue
  50. BIN
      20_脚手架/vue3_test/20.src_Teleport/assets/logo.png
  51. 21
      20_脚手架/vue3_test/20.src_Teleport/components/Child.vue
  52. 50
      20_脚手架/vue3_test/20.src_Teleport/components/Dialog.vue
  53. 22
      20_脚手架/vue3_test/20.src_Teleport/components/Son.vue
  54. 10
      20_脚手架/vue3_test/20.src_Teleport/main.js
  55. 31
      20_脚手架/vue3_test/21.src_Suspense/App.vue
  56. BIN
      20_脚手架/vue3_test/21.src_Suspense/assets/logo.png
  57. 29
      20_脚手架/vue3_test/21.src_Suspense/components/Child.vue
  58. 10
      20_脚手架/vue3_test/21.src_Suspense/main.js
  59. 40
      20_脚手架/vue3_test/3.src_ref函数的使用/App.vue
  60. BIN
      20_脚手架/vue3_test/3.src_ref函数的使用/assets/logo.png
  61. 10
      20_脚手架/vue3_test/3.src_ref函数的使用/main.js
  62. 59
      20_脚手架/vue3_test/4.src_reactive函数的使用/App.vue
  63. BIN
      20_脚手架/vue3_test/4.src_reactive函数的使用/assets/logo.png
  64. 10
      20_脚手架/vue3_test/4.src_reactive函数的使用/main.js
  65. 73
      20_脚手架/vue3_test/5.src_vue3的响应式原理/App.vue
  66. BIN
      20_脚手架/vue3_test/5.src_vue3的响应式原理/assets/logo.png
  67. 10
      20_脚手架/vue3_test/5.src_vue3的响应式原理/main.js
  68. 26
      20_脚手架/vue3_test/6.src_setup的两个注意点/App.vue
  69. BIN
      20_脚手架/vue3_test/6.src_setup的两个注意点/assets/logo.png
  70. 36
      20_脚手架/vue3_test/6.src_setup的两个注意点/components/demo.vue
  71. 10
      20_脚手架/vue3_test/6.src_setup的两个注意点/main.js
  72. 13
      20_脚手架/vue3_test/7.src_Vue3的computed/App.vue
  73. BIN
      20_脚手架/vue3_test/7.src_Vue3的computed/assets/logo.png
  74. 50
      20_脚手架/vue3_test/7.src_Vue3的computed/components/demo.vue
  75. 10
      20_脚手架/vue3_test/7.src_Vue3的computed/main.js
  76. 13
      20_脚手架/vue3_test/8.src_watch函数/App.vue
  77. BIN
      20_脚手架/vue3_test/8.src_watch函数/assets/logo.png
  78. 87
      20_脚手架/vue3_test/8.src_watch函数/components/demo.vue
  79. 10
      20_脚手架/vue3_test/8.src_watch函数/main.js
  80. 13
      20_脚手架/vue3_test/9.src_watch监视ref的数据的说明/App.vue
  81. BIN
      20_脚手架/vue3_test/9.src_watch监视ref的数据的说明/assets/logo.png
  82. 67
      20_脚手架/vue3_test/9.src_watch监视ref的数据的说明/components/demo.vue
  83. 10
      20_脚手架/vue3_test/9.src_watch监视ref的数据的说明/main.js
  84. 24
      20_脚手架/vue3_test/README.md
  85. 5
      20_脚手架/vue3_test/babel.config.js
  86. 19
      20_脚手架/vue3_test/jsconfig.json
  87. 19557
      20_脚手架/vue3_test/package-lock.json
  88. 43
      20_脚手架/vue3_test/package.json
  89. BIN
      20_脚手架/vue3_test/public/favicon.ico
  90. 17
      20_脚手架/vue3_test/public/index.html
  91. 31
      20_脚手架/vue3_test/src/App.vue
  92. BIN
      20_脚手架/vue3_test/src/assets/logo.png
  93. 29
      20_脚手架/vue3_test/src/components/Child.vue
  94. 10
      20_脚手架/vue3_test/src/main.js
  95. 5
      20_脚手架/vue3_test/vue.config.js
  96. 34
      20_脚手架/vue_code/37.src_组件内路由守卫/App.vue
  97. BIN
      20_脚手架/vue_code/37.src_组件内路由守卫/assets/logo.png
  98. 23
      20_脚手架/vue_code/37.src_组件内路由守卫/main.js
  99. 38
      20_脚手架/vue_code/37.src_组件内路由守卫/pages/About.vue
  100. 34
      20_脚手架/vue_code/38.src_路由的hash和history工作模式/App.vue
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,23 +0,0 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

@ -1,26 +0,0 @@
<template>
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld
}
}
</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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,58 +0,0 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,13 +0,0 @@
<template>
<Demo/>
</template>
<script>
import {reactive} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,54 +0,0 @@
<template>
<h2>当前求和为{{ sum }}</h2>
<button @click="sum++">点击+1</button>
<hr>
<h2>当前信息为{{ msg }}</h2>
<button @click="msg+='!'">修改信息</button>
<hr>
<h2>姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<h2>薪资{{ person.job.j1.salary }}</h2>
<button @click="person.name+='~'">修改姓名</button>
<button @click="person.age++">修改年龄</button>
<button @click="person.job.j1.salary++">修改薪资</button>
<h2></h2>
</template>
<script>
import {reactive, ref, watch, watchEffect} from "vue";
export default {
name: 'Demo',
setup() {
let sum = ref(0)
let msg = ref('你好呀')
let person = reactive({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
// refvalue
// watch(person, (newValue, oldValue) => {
// console.log('person', newValue, oldValue)
// })
watchEffect(() => {
const x1 = sum.value
const x2 = person.job.j1.salary
console.log('watchEffect所指定的回调执行了')
})
return {
sum,
msg,
person
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,22 +0,0 @@
<template>
<button @click="isShowDemo=!isShowDemo">点击展示隐藏</button>
<Demo v-if="isShowDemo"/>
</template>
<script>
import {ref} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup() {
let isShowDemo = ref(true)
return {
isShowDemo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,76 +0,0 @@
<template>
<h2>当前求和为{{ sum }}</h2>
<button @click="sum++">点击+1</button>
</template>
<script>
import {ref, onBeforeMount, onMounted, onBeforeUpdate,onUpdated,onBeforeUnmount,onUnmounted} from "vue";
export default {
name: 'Demo',
setup() {
console.log("___setup___")
let sum = ref(0)
// API
onBeforeMount(()=>{
console.log("___onBeforeMount___")
})
onMounted(()=>{
console.log("___onMounted___")
})
onBeforeUpdate(()=>{
console.log("___onBeforeUpdate___")
})
onUpdated(()=>{
console.log("___onUpdated___")
})
onBeforeUnmount(()=>{
console.log("___onBeforeUnmount___")
})
onUnmounted(()=>{
console.log("___onUnmounted___")
})
return {
sum
}
},
// // 使
// beforeCreate() {
// console.log('---beforeCreate---')
// },
//
// created() {
// console.log("---created---")
// },
//
// beforeMount() {
// console.log("---beforeMount---")
// },
//
// mounted() {
// console.log("---mounted---")
// },
//
// beforeUpdate() {
// console.log("---beforeUpdate---")
// },
//
// updated() {
// console.log("---updated---")
// },
//
// beforeUnmount() {
// console.log("---beforeUnmount---")
// },
//
// unmounted() {
// console.log("---unmounted---")
// }
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,22 +0,0 @@
<template>
<button @click="isShowDemo=!isShowDemo">点击展示隐藏</button>
<Demo v-if="isShowDemo"/>
</template>
<script>
import {ref} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup() {
let isShowDemo = ref(true)
return {
isShowDemo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,26 +0,0 @@
<template>
<h2>当前求和为{{ sum }}</h2>
<button @click="sum++">点击+1</button>
<hr>
<h2>当前点击时鼠标的坐标为x:{{point.x}} y:{{point.y}}</h2>
</template>
<script>
import {ref} from "vue";
import usePoint from "@/hooks/usePoint";
export default {
name: 'Demo',
setup() {
console.log("___setup___")
let sum = ref(0)
let point = usePoint()
return {
sum,
point
}
},
}
</script>

@ -1,24 +0,0 @@
import {onBeforeUnmount, onMounted, reactive} from "vue";
export default function() {
let point = reactive({
x: 0,
y: 0
})
function savePoint() {
console.log(event.pageX, event.pageY)
point.x = event.pageX
point.y = event.pageY
}
onMounted(() => {
window.addEventListener('click', savePoint)
})
onBeforeUnmount(() => {
window.removeEventListener('click', savePoint)
})
return point
}

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,22 +0,0 @@
<template>
<button @click="isShowDemo=!isShowDemo">点击展示隐藏</button>
<Demo v-if="isShowDemo"/>
</template>
<script>
import {ref} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup() {
let isShowDemo = ref(true)
return {
isShowDemo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,37 +0,0 @@
<template>
<h2>{{ person }}</h2>
<h2>姓名{{ name }}</h2>
<h2>年龄{{ age }}</h2>
<h2>薪资{{ job.j1.salary }}</h2>
<button @click="name+='~'">修改姓名</button>
<button @click="age++">修改年龄</button>
<button @click="job.j1.salary++">修改薪资</button>
</template>
<script>
import {reactive,toRef,toRefs} from "vue";
export default {
name: 'Demo',
setup() {
let person = reactive({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
return {
person,
// name:toRef(person, 'name'),
// age: toRef(person, 'age'),
// salary: toRef(person.job.j1, 'salary')
...toRefs(person)
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,22 +0,0 @@
<template>
<button @click="isShowDemo=!isShowDemo">点击展示隐藏</button>
<Demo v-if="isShowDemo"/>
</template>
<script>
import {ref} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup() {
let isShowDemo = ref(true)
return {
isShowDemo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,39 +0,0 @@
<template>
<h4>当前的x值是 {{ x.y }}</h4>
<button @click="x++">点击+1</button>
<h2>{{ person }}</h2>
<h2>姓名{{ name }}</h2>
<h2>年龄{{ age }}</h2>
<h2>薪资{{ job.j1.salary }}</h2>
<button @click="name+='~'">修改姓名</button>
<button @click="age++">修改年龄</button>
<button @click="job.j1.salary++">修改薪资</button>
</template>
<script>
import {reactive, ref, toRef, toRefs, shallowReactive, shallowRef} from "vue";
export default {
name: 'Demo',
setup() {
// let person = shallowReactive({ //
let person = shallowReactive({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
let x = shallowRef({y:0}) //shallow
return {
person,
x,
...toRefs(person)
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,22 +0,0 @@
<template>
<button @click="isShowDemo=!isShowDemo">点击展示隐藏</button>
<Demo v-if="isShowDemo"/>
</template>
<script>
import {ref} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup() {
let isShowDemo = ref(true)
return {
isShowDemo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,41 +0,0 @@
<template>
<h4>当前求和为 {{ sum }}</h4>
<button @click="sum++">点击+1</button>
<h2>姓名{{ name }}</h2>
<h2>年龄{{ age }}</h2>
<h2>薪资{{ job.j1.salary }}</h2>
<button @click="name+='~'">修改姓名</button>
<button @click="age++">修改年龄</button>
<button @click="job.j1.salary++">修改薪资</button>
</template>
<script>
import {reactive, ref, toRefs, readonly, shallowReadonly} from "vue";
export default {
name: 'Demo',
setup() {
let sum = ref(0)
let person = reactive({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
// person = readonly(person)
// person = shallowReadonly(person)
// sum = readonly(sum)
return {
sum,
...toRefs(person)
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,22 +0,0 @@
<template>
<button @click="isShowDemo=!isShowDemo">点击展示隐藏</button>
<Demo v-if="isShowDemo"/>
</template>
<script>
import {ref} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup() {
let isShowDemo = ref(true)
return {
isShowDemo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,62 +0,0 @@
<template>
<h4>当前求和为 {{ sum }}</h4>
<button @click="sum++">点击+1</button>
<h2>姓名{{ name }}</h2>
<h2>年龄{{ age }}</h2>
<h2>薪资{{ job.j1.salary }}</h2>
<h3 v-show="person.car">车辆信息{{ person.car }}</h3>
<button @click="name+='~'">修改姓名</button>
<button @click="age++">修改年龄</button>
<button @click="job.j1.salary++">修改薪资</button>
<button @click="showRawPerson">输出最原始的person</button>
<button @click="addCar">给人添加一台车</button>
<button v-show="person.car" @click="person.car.name += '!'">修改车名</button>
<button v-show="person.car" @click="changeCarPrice">修改价格</button>
</template>
<script>
import {reactive, ref, toRefs, toRaw, markRaw} from "vue";
export default {
name: 'Demo',
setup() {
let sum = ref(0)
let person = reactive({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
function showRawPerson() {
console.log(person)
const p = toRaw(person)
console.log(p)
}
function addCar() {
let car = {name:'奔驰', price:40}
// person.car = car
person.car = markRaw(car)
console.log(person)
}
function changeCarPrice() {
person.car.price++
console.log(person.car.price)
}
return {
sum,
person,
...toRefs(person),
showRawPerson,
addCar,
changeCarPrice
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,44 +0,0 @@
<template>
<input type="text" v-model="keyWord">
<h3>{{keyWord}}</h3>
</template>
<script>
import {ref, customRef} from "vue";
export default {
name: 'App',
setup() {
// ref
function myRef(value) {
let timer
// console.log('---myRef---', value)
return customRef((track,trigger)=>{
return {
get() {
console.log(`有人从myRef这个容器中读取数据了,我把${value}给他了`)
track() // vue
return value
},
set(newValue) {
console.log(`有人从myRef这个容器中数据改为了:${newValue}`)
clearTimeout(timer)
timer = setTimeout(()=>{
value = newValue
trigger() //vue
}, 500)
}
}
})
}
// let keyWord = ref('hello') // 使ref
let keyWord = myRef('hello')
return {
keyWord,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,31 +0,0 @@
<template>
<div className="app">
<h3>我是app组件{{ name }}-{{ price }}</h3>
<child/>
</div>
</template>
<script>
import child from "@/components/Child.vue";
import {reactive, toRefs, provide} from "vue";
export default {
name: 'App',
components: {child},
setup() {
let car = reactive({
name: '奔驰',
price: '40W'
})
provide('car', car) //
return {...toRefs(car)}
}
}
</script>
<style>
.app {
background-color: gray;
padding: 10px;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,21 +0,0 @@
<template>
<div class="child">
<h3>我是child组件</h3>
<son/>
</div>
</template>
<script>
import son from "@/components/Son.vue";
export default {
name: "Child",
components:{son}
}
</script>
<style>
.child{
background-color: skyblue;
padding: 10px;
}
</style>

@ -1,26 +0,0 @@
<template>
<div class="son">
<h3>我是son组件{{car.name}}-{{car.price}}</h3>
</div>
</template>
<script>
import {inject} from "vue";
export default {
name: "Son",
setup() {
let car = inject('car')
console.log('---son---', car)
return {car}
}
}
</script>
<style scoped>
.son{
background-color: orange;
padding: 10px;
}
</style>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,35 +0,0 @@
<template>
<div class="app">
<h3>我是app组件</h3>
</div>
</template>
<script>
import {reactive, ref, toRefs, provide, readonly, isReactive, isRef, isReadonly, isProxy} from "vue";
export default {
name: 'App',
setup() {
let car = reactive({
name:'奔驰',
price: '40W'
})
let car2 = readonly(car)
let sum = ref(0)
console.log(isRef(sum))
console.log(isReactive(car))
console.log(isReadonly(car2))
console.log(isProxy(car))
return {...toRefs(car)}
}
}
</script>
<style>
.app{
background-color: gray;
padding: 10px;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,28 +0,0 @@
<template>
<h1>个人信息</h1>
<h2>姓名{{name}}</h2>
<h2>年龄{{age}}</h2>
<button @click="sayHello">点击</button>
</template>
<script>
export default {
name: 'App',
setup() {
//
let name = '张三'
let age = 19
//
function sayHello() {
alert(`名字:${name},年龄:${age}`)
}
return {
name,
age,
sayHello,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,23 +0,0 @@
<template>
<div className="app">
<h3>我是app组件</h3>
<child/>
</div>
</template>
<script>
import child from "@/components/Child";
import {reactive, toRefs, provide} from "vue";
export default {
name: 'App',
components: {child},
}
</script>
<style>
.app {
background-color: gray;
padding: 10px;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,21 +0,0 @@
<template>
<div class="child">
<h3>我是child组件</h3>
<son/>
</div>
</template>
<script>
import son from "@/components/Son";
export default {
name: "Child",
components:{son}
}
</script>
<style>
.child{
background-color: skyblue;
padding: 10px;
}
</style>

@ -1,50 +0,0 @@
<template>
<div>
<button @click="isShow=true">点我弹个窗</button>
<teleport to="body">
<div v-if="isShow" class="mask">
<div class="dialog">
<h3>这是一个弹窗</h3>
<h4>内容</h4>
<h4>内容</h4>
<h4>内容</h4>
<button @click="isShow=false">关闭弹窗</button>
</div>
</div>
</teleport>
</div>
</template>
<script>
import {ref} from "vue";
export default {
name: "Dialog",
setup() {
let isShow = ref(false)
return {isShow}
}
}
</script>
<style>
.mask {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
}
.dialog {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
height: 300px;
background-color: green;
}
</style>

@ -1,22 +0,0 @@
<template>
<div class="son">
<h3>我是son组件</h3>
<Dialog/>
</div>
</template>
<script>
import Dialog from "@/components/Dialog.vue";
export default {
name: "Son",
components:{Dialog}
}
</script>
<style>
.son{
background-color: orange;
padding: 10px;
}
</style>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,31 +0,0 @@
<template>
<div className="app">
<h3>我是app组件</h3>
<Suspense>
<template v-slot:default>
<Child/>
</template>
<template v-slot:fallback>
<h3>加载中</h3>
</template>
</Suspense>
</div>
</template>
<script>
// import child from "@/components/Child"; //
import {defineAsyncComponent} from 'vue';
const Child = defineAsyncComponent(() => import('./components/Child.vue')) //
export default {
name: 'App',
components: {Child},
}
</script>
<style>
.app {
background-color: gray;
padding: 10px;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,29 +0,0 @@
<template>
<div class="child">
<h3>我是child组件</h3>
{{sum}}
</div>
</template>
<script>
import {ref} from "vue";
export default {
name: "Child",
setup() {
let sum = ref(0)
return new Promise((resolve,reject)=> {
setTimeout(()=>{
resolve({sum})
}, 1000)
})
}
}
</script>
<style>
.child{
background-color: skyblue;
padding: 10px;
}
</style>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,40 +0,0 @@
<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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,59 +0,0 @@
<template>
<h1>个人信息</h1>
<h2>姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<h2>工作种类{{ person.job.type }}</h2>
<h2>薪水{{ person.job.salary }}</h2>
<h2>爱好{{ person.hobby }}</h2>
<h2>c的值{{ person.job.a.b.c }}</h2>
<button @click="changeInfo">修改信息</button>
</template>
<script>
import {ref, reactive} from "vue";
export default {
name: 'App',
setup() {
//
// let name = ref('')
// let age = ref(19)
// let job = reactive({
// type: '',
// salary: '30K',
// a: {
// b:{
// c: 666
// }
// }
// })
// let hobby = reactive(['','',''])
let person = reactive({
name: '张三',
age: 18,
job:{
type: '前端工程师',
salary: '30K',
a: {
b:{
c: 666
}
}
},
hobby: ['抽烟','喝酒','烫头']
})
function changeInfo() {
person.name = '李四'
person.age = 88
person.job.type = '后端工程师'
person.job.salary = '31K'
person.hobby[0] = '测试'
}
return {
person,
changeInfo,
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,73 +0,0 @@
<template>
<h1>个人信息</h1>
<h2 v-show="person.name">姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<h2 v-show="person.sex">性别{{ person.sex }}</h2>
<h2>工作种类{{ person.job.type }}</h2>
<h2>薪水{{ person.job.salary }}</h2>
<h2>爱好{{ person.hobby }}</h2>
<h2>c的值{{ person.job.a.b.c }}</h2>
<button @click="changeInfo">修改信息</button>
<button @click="addSex">添加性别</button>
<button @click="deleteName">删除姓名</button>
</template>
<script>
import {ref, reactive} from "vue";
export default {
name: 'App',
setup() {
//
// let name = ref('')
// let age = ref(19)
// let job = reactive({
// type: '',
// salary: '30K',
// a: {
// b:{
// c: 666
// }
// }
// })
// let hobby = reactive(['','',''])
let person = reactive({
name: '张三',
age: 18,
job: {
type: '前端工程师',
salary: '30K',
a: {
b: {
c: 666
}
}
},
hobby: ['抽烟', '喝酒', '烫头']
})
function changeInfo() {
person.name = '李四'
person.age = 88
person.job.type = '后端工程师'
person.job.salary = '31K'
person.hobby[0] = '测试'
}
function addSex() {
person.sex = '男'
}
function deleteName() {
delete person.name
}
return {
person,
changeInfo,
addSex,
deleteName
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,26 +0,0 @@
<template>
<Demo @hello="showHelloMsg" msg="你好" user="Roger">
<template v-slot:slot1>
<span>Roger</span>
</template>
</Demo>
</template>
<script>
import {reactive} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
setup(){
function showHelloMsg(value) {
alert(`showHelloMsg:${value}`)
}
return {
showHelloMsg
}
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,36 +0,0 @@
<template>
<h1>个人信息</h1>
<h2>姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<button @click="test">触发showHelloMsg</button>
</template>
<script>
import {reactive} from "vue";
export default {
name: 'Demo',
beforeCreate() {
console.log('---beforeCreate---')
},
props: ['msg', 'user'],
emits: ['hello'],
setup(props, context) {
console.log('---setup---', context) // $attrs $emits $slots
console.log('---setup---', context.slots) // $attrs $emits $slots
let person = reactive({
name: '张三',
age: 18
})
function test() {
context.emit('hello',666)
}
return {
person,
test
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,13 +0,0 @@
<template>
<Demo/>
</template>
<script>
import {reactive} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,50 +0,0 @@
<template>
<h1>个人信息</h1>
<input type="text" v-model="person.firstName">
<br>
<input type="text" v-model="person.lastName">
<br>
<span>全名 {{person.fullName}}</span>
<br>
全名<input type="text" v-model="person.fullName">
</template>
<script>
import {reactive, computed} from "vue";
export default {
name: 'Demo',
// computed:{
// fullName() {
// return this.person.firstName+'-'+this.person.lastName
// }
// },
setup() {
let person = reactive({
firstName: '张',
lastName: '三'
})
// -
person.fullName = computed(()=>{
return person.firstName + '-' + person.lastName
})
// -
person.fullName = computed({
get() {
return person.firstName + '-' + person.lastName
},
set(val) {
const nameArr = val.split('-')
person.firstName = nameArr[0]
person.lastName = nameArr[1]
}
})
return {
person,
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,13 +0,0 @@
<template>
<Demo/>
</template>
<script>
import {reactive} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,87 +0,0 @@
<template>
<h2>当前求和为{{ sum }}</h2>
<button @click="sum++">点击+1</button>
<hr>
<h2>当前信息为{{ msg }}</h2>
<button @click="msg+='!'">修改信息</button>
<hr>
<h2>姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<h2>薪资{{ person.job.j1.salary }}</h2>
<button @click="person.name+='~'">修改姓名</button>
<button @click="person.age++">修改年龄</button>
<button @click="person.job.j1.salary++">修改薪资</button>
<h2></h2>
</template>
<script>
import {reactive, ref, watch} from "vue";
export default {
name: 'Demo',
// watch: {
// // Vue2
// // sum(newValue, oldValue) {
// // console.log('sum', newValue, oldValue)
// // }
// // Vue2
// // sum: {
// // immediate: true,
// // deep: true,
// // handler(newValue, oldValue) {
// // console.log('sum', newValue, oldValue)
// // }
// // }
// },
setup() {
let sum = ref(0)
let msg = ref('你好呀')
let person = reactive({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
// ref
// watch(sum, (newValue, oldValue) => {
// console.log('sum', newValue, oldValue)
// }, {deep: true, immediate: true})
// ref
watch([sum, msg], (newValue, oldValue) => {
console.log('sum和msg的值变化了', newValue, oldValue)
}, {immediate: true})
// reactiveoldValuedeep
// watch(person, (newValue, oldValue) => {
// console.log('person', newValue, oldValue)
// }, {deep: false})
// reactive
// watch(()=>person.age, (newValue,oldValue)=>{
// console.log('person.age', newValue, oldValue)
// })
// reactive
watch([() => person.name, () => person.age], (newValue, oldValue) => {
console.log('person.age和.name对象的值变了', newValue, oldValue)
})
//
watch(() => person.job, (newValue, oldValue) => {
console.log('person.job对象的值变了', newValue, oldValue)
}, {deep: true})
return {
sum,
msg,
person
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,13 +0,0 @@
<template>
<Demo/>
</template>
<script>
import {reactive} from "vue";
import Demo from "@/components/demo.vue";
export default {
name: 'App',
components: {Demo},
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,67 +0,0 @@
<template>
<h2>当前求和为{{ sum }}</h2>
<button @click="sum++">点击+1</button>
<hr>
<h2>当前信息为{{ msg }}</h2>
<button @click="msg+='!'">修改信息</button>
<hr>
<h2>姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<h2>薪资{{ person.job.j1.salary }}</h2>
<button @click="person.name+='~'">修改姓名</button>
<button @click="person.age++">修改年龄</button>
<button @click="person.job.j1.salary++">修改薪资</button>
<h2></h2>
</template>
<script>
import {reactive, ref, watch} from "vue";
export default {
name: 'Demo',
// watch: {
// // Vue2
// // sum(newValue, oldValue) {
// // console.log('sum', newValue, oldValue)
// // }
// // Vue2
// // sum: {
// // immediate: true,
// // deep: true,
// // handler(newValue, oldValue) {
// // console.log('sum', newValue, oldValue)
// // }
// // }
// },
setup() {
let sum = ref(0)
let msg = ref('你好呀')
let person = ref({
name: '张三',
age: 18,
job: {
j1: {
salary: 20
}
}
})
// refvalue
// watch(person.value, (newValue, oldValue) => {
// console.log('person', newValue, oldValue)
// })
// refdeep
watch(person, (newValue, oldValue) => {
console.log('person的值变了', newValue, oldValue)
},{deep: true})
return {
sum,
msg,
person
}
}
}
</script>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,24 +0,0 @@
# vue3_test
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

@ -1,5 +0,0 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

@ -1,19 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

File diff suppressed because it is too large Load Diff

@ -1,43 +0,0 @@
{
"name": "vue3_test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"vue": "^3.2.13"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

@ -1,31 +0,0 @@
<template>
<div className="app">
<h3>我是app组件</h3>
<Suspense>
<template v-slot:default>
<Child/>
</template>
<template v-slot:fallback>
<h3>加载中</h3>
</template>
</Suspense>
</div>
</template>
<script>
// import child from "@/components/Child"; //
import {defineAsyncComponent} from 'vue';
const Child = defineAsyncComponent(() => import('./components/Child.vue')) //
export default {
name: 'App',
components: {Child},
}
</script>
<style>
.app {
background-color: gray;
padding: 10px;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,29 +0,0 @@
<template>
<div class="child">
<h3>我是child组件</h3>
{{sum}}
</div>
</template>
<script>
import {ref} from "vue";
export default {
name: "Child",
setup() {
let sum = ref(0)
return new Promise((resolve,reject)=> {
setTimeout(()=>{
resolve({sum})
}, 1000)
})
}
}
</script>
<style>
.child{
background-color: skyblue;
padding: 10px;
}
</style>

@ -1,10 +0,0 @@
// 引入的不再是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')

@ -1,5 +0,0 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false, // 关闭语法检查
})

@ -1,34 +0,0 @@
<template>
<div>
<div class="row">
<Banner/>
</div>
<div class="row">
<div class="col-xs-2 col-xs-offset-2">
<div class="list-group">
<!-- router-link replace push模式 设置为replace后无法后退默认为push模式-->
<router-link class="list-group-item" active-class="active" :to="{name:'guanyu'}">About</router-link>
<router-link class="list-group-item" active-class="active" to="/home">Home</router-link>
<!-- <a class="list-group-item active" href="./about.html">About</a>-->
<!-- <a class="list-group-item" href="./home.html">Home</a>-->
</div>
</div>
<div class="col-xs-6">
<div class="panel">
<div class="panel-body">
<router-view></router-view>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import Banner from "@/components/Banner.vue";
export default {
name: "App",
components: {Banner}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,23 +0,0 @@
// 引入Vue
import Vue from "vue";
// 引入App
import App from "./App";
// 引入VueRouter
import VueRouter from "vue-router";
// 引入router
import router from "@/router";
// 设置Vue
Vue.config.productionTip = false
// 使用插件
Vue.use(VueRouter)
// 实例化Vue
new Vue({
components: {
App
},
render: h => h(App),
router: router,
}).$mount('#app')

@ -1,38 +0,0 @@
<template>
<h2>我是About的内容</h2>
</template>
<script>
export default {
name: "About",
mounted() {
console.log('About组件挂着完成', this)
window.aboutRoute = this.$route
window.aboutRouter = this.$router
},
beforeDestroy() {
console.log('About组件即将销毁')
},
//
beforeRouteEnter(to, from, next) {
console.log('APP---beforeRouteEnter')
if (to.meta.isAuth){
if (localStorage.getItem('school') === 'atguigu') {
next()
}else{
alert('学校名称错误,无权查看!')
}
}else{
next()
}
},
//
// beforeRouteLeave(to, from, next) {
//
// }
}
</script>
<style scoped>
</style>

@ -1,34 +0,0 @@
<template>
<div>
<div class="row">
<Banner/>
</div>
<div class="row">
<div class="col-xs-2 col-xs-offset-2">
<div class="list-group">
<!-- router-link replace push模式 设置为replace后无法后退默认为push模式-->
<router-link class="list-group-item" active-class="active" :to="{name:'guanyu'}">About</router-link>
<router-link class="list-group-item" active-class="active" to="/home">Home</router-link>
<!-- <a class="list-group-item active" href="./about.html">About</a>-->
<!-- <a class="list-group-item" href="./home.html">Home</a>-->
</div>
</div>
<div class="col-xs-6">
<div class="panel">
<div class="panel-body">
<router-view></router-view>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import Banner from "@/components/Banner.vue";
export default {
name: "App",
components: {Banner}
}
</script>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save