邓宏
3 years ago
6 changed files with 96 additions and 52 deletions
@ -1,54 +1,90 @@ |
|||||
<script setup> |
<style lang='less' scoped> |
||||
import { ref, useAttrs, useSlots, useCssVars, inject, defineExpose, onMounted } from 'vue' |
a { |
||||
|
color: #42b983; |
||||
console.log(inject("store"),'---------------store--------') |
background: v-bind(color); |
||||
console.log(useAttrs(),'-------useAttrs-------') |
} |
||||
|
.demo{ |
||||
console.log(useSlots(),'---------useSlots--') |
color:blue; |
||||
defineProps({ |
span{ |
||||
msg: String |
font-weight: bold; |
||||
}) |
text-decoration: initial; |
||||
useCssVars(e=>{ |
font-size:40px; |
||||
console.log(e,"-----------ctx----") |
} |
||||
}) |
} |
||||
const emit=defineEmits(['close']) |
</style> |
||||
console.log(emit,'-------emit-----------') |
<style lang="less" module="cssName"> |
||||
const count = ref(0) |
.demo{ |
||||
const color="#342e91" |
color:red; |
||||
defineExpose({ // 暴露数据,提供父元素使用 |
span{ |
||||
count |
font-weight: bold; |
||||
}) |
text-decoration: initial; |
||||
</script> |
font-size:40px; |
||||
|
} |
||||
|
} |
||||
|
</style> |
||||
<template> |
<template> |
||||
<h1 v-bind="$attrs">{{ msg }}</h1> |
<h1 v-bind="$attrs">{{ msg }}</h1> |
||||
<slot/> |
<slot/> |
||||
<slot name="demo"/> |
<slot name="demo"/> |
||||
<p> |
<p v-my-directive> |
||||
Recommended IDE setup: |
Recommended IDE setup: |
||||
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a> |
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a> |
||||
+ |
+ |
||||
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a> |
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a> |
||||
</p> |
</p> |
||||
|
<!-- v-memo 类似于 v-one 数组内的值变换时会更新 --> |
||||
<p> |
<p v-memo="[b]"> |
||||
|
{{count}} |
||||
<a href="https://vitejs.dev/guide/features.html" target="_blank"> |
<a href="https://vitejs.dev/guide/features.html" target="_blank"> |
||||
Vite Documentation |
Vite Documentation |
||||
</a> |
</a> |
||||
| |
| |
||||
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a> |
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a> |
||||
</p> |
</p> |
||||
|
<div class="demo">1-<span>2</span></div> |
||||
<button type="button" @click="count++">count is: {{ count }}</button> |
<button type="button" @click="count++">count is: {{ count }}</button> |
||||
<p> |
<p :class="cssName.demo"> |
||||
Edit |
<span>Edit</span>{{foo}} |
||||
<code>components/HelloWorld.vue</code> to test hot module replacement. |
<code>components/HelloWorld.vue</code> to test hot module replacement. |
||||
</p> |
</p> |
||||
</template> |
</template> |
||||
|
<script setup> |
||||
|
import { ref, useAttrs, useSlots, useCssVars, inject, defineExpose } from 'vue' |
||||
|
|
||||
<style lang='less' scoped> |
console.log(inject("store"),'---------------store--------') |
||||
a { |
console.log(useAttrs(),'-------useAttrs-------') |
||||
color: #42b983; |
console.log(useSlots(),'---------useSlots--') |
||||
background: v-bind(color); |
defineProps({ |
||||
} |
msg: String |
||||
</style> |
}) |
||||
|
useCssVars(e=>{ |
||||
|
console.log(e,"-----------ctx----") |
||||
|
}) |
||||
|
const emit=defineEmits(['close']) |
||||
|
console.log(emit,'-------emit-----------') |
||||
|
const count = ref(0) |
||||
|
const color="#342e91" |
||||
|
const b=ref('ddd') |
||||
|
window.b=b |
||||
|
defineExpose({ // 暴露数据,提供父元素使用 |
||||
|
count |
||||
|
}) |
||||
|
|
||||
|
const vMyDirective={ |
||||
|
// 指令具有一组生命周期钩子: |
||||
|
// 在绑定元素的 attribute 或事件监听器被应用之前调用 |
||||
|
created(el, binding, vnode) {}, |
||||
|
// 在绑定元素的父组件挂载之前调用 |
||||
|
beforeMount() {}, |
||||
|
// 在绑定元素的父组件挂载之后调用 |
||||
|
mounted() {}, |
||||
|
// 在包含组件的 VNode 更新之前调用 |
||||
|
beforeUpdate() {}, |
||||
|
// 在包含组件的 VNode 及其子组件的 VNode 更新之后调用 |
||||
|
updated() {}, |
||||
|
// 在绑定元素的父组件卸载之前调用 |
||||
|
beforeUnmount() {}, |
||||
|
// 在绑定元素的父组件卸载之后调用 |
||||
|
unmounted() {} |
||||
|
} |
||||
|
</script> |
||||
|
Loading…
Reference in new issue