vue3tup语法糖事件引用和写法

更新时间:2023-06-26 22:29:35 阅读: 评论:0

vue3tup语法糖事件引⽤和写法
tup基础⽤法
tup是vue3新增的⼀个属性,默认写法是在代码中⽤tup⽅法,然后在tup中return。
tup(){
const func = () => {
炒白术的功效与作用//这⾥写⽅法⾥的内容
}
红烧牛尾return func
}
⽤tup语法糖则⽆需这么繁琐,并且不需要使⽤this,切记。
不倒翁的制作方法
<script tup>
/
/直接写⽅法,在dom中直接调⽤即可
const editFunc = () => {}
</script>期货策略
<template>
<div  @click="editDrawer">编辑按钮</div>
</template>
tup中使⽤watch,props,emit
props⽤defineProps代替。
emit⽤defineEmits代替。
watch监听props,值以函数返回值的形式传⼊。
<script tup>
const props = defineProps({
rightMenuStyle: String,
rightMenu: String
})
const emit = defineEmits(['editDrawer'])
watch(()=>props.rightMenuStyle, (newVal, oldVal)=>{
if(val){
种植石斛state.styleObj = JSON.par(newVal)
}
}, {deep: true, immediate: true})
const editDrawer = (val) => {
正方形纸能折什么
emit('editDrawer', pe)
}
</script>
<template>
<div  @click="editDrawer">编辑按钮</div>
</template>
watch监听多个值
watch([()=>props.rightMenuStyle, ()=>props.rightMenu], (newVal, oldVal)=>{
鱼的记忆有多久// 请注意,监听多个值,有⼀个值变化,watch就会执⾏,所以为了不频繁触发,不建议同时监听多个值
}, {deep: true, immediate: true})
预防校园欺凌内容| 本⽂章会⼀直更新,请持续关注哦,⼀起学习!

本文发布于:2023-06-26 22:29:35,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1046862.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:写法   监听   函数   值以   属性   默认   语法
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图