曹え 5811 发布于:2022-07-08 12:03:15
语法糖模式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | <script setup> import { onBeforeMount, onBeforeUnmount, onBeforeUpdate, onUnmounted, onUpdated, onMounted, ref, onActivated, onDeactivated, } from "vue" ; defineProps<{ msg: string }>(); const count = ref( 0 ); const name = ref( "彭" ); let update = () => { console.log( "update" ); name.value = "点击了" ; }; function table() { const gander = "男" ; return { gander, }; } let table1 = table(); onBeforeMount(() => { console.log( "onBeforeMount" ); console.log(name.value); console.log(document.getElementById( "count" )); }); onMounted(() => { console.log( "onMounted" ); console.log(name.value); console.log(document.getElementById( "count" )); }); onActivated(() => { console.log( "onActivated" ); }); onDeactivated(() => { console.log( "onDeactivated" ); }); onBeforeUpdate(() => { console.log( "onBeforeUpdate" ); console.log(name.value); }); onUpdated(() => { console.log( "onUpdated" ); console.log(name.value); }); onBeforeUnmount(() => { console.log( "onBeforeUnmount" ); }); onUnmounted(() => { console.log( "onUnmounted" ); }); </script> <template> <h1>{{ msg }}</h1> <h2 @click = "update" >{{ name }}</h2> <h4 id= "count" >{{ count }}</h4> <h4>{{ table1.gander }}</h4> </template> <style scoped> a { color: #42b983; } label { margin: 0 0 .5em; font-weight: bold; } code { background-color: #eee; padding: 2px 4px; border-radius: 4px; color: # 304455 ; } </style> |
登录后可以留言提问!