vue3中被抛弃的方法,过滤器和tag

编程入门 行业动态 更新时间:2024-10-07 02:29:23

vue3中被抛弃的方法,<a href=https://www.elefans.com/category/jswz/34/1771166.html style=过滤器和tag"/>

vue3中被抛弃的方法,过滤器和tag

vue3重新定义了ctx,重定义的ctx中有一些vue2的方法没有被添加,只能通过后续npm安装后才能使用

// vue2的写法
<template><p>{{ data | fliter() }}</p>
</template>
<script>fliter:{fliter(){...}}
</script>

vue2中可以使用传统过滤器,而到了vue3中则直接使用函数替代过滤器

// vue3的写法
<template><p>{{ fliter() }}</p>
</template>
<script>motheds:{fliter(){...}}
</script>

vue2中router-link有tag,在vue3中tag方法不生效
主要原因:vue-routerv3.1.x以上版本,新增“v-slot”,推荐使用‘custom v-slot’代替

// vue2写法
<router-link to="/about" tag="li">About Us</router-link>
// vue3写法
<router-link to="/about" custom v-slot="{ navigate }"><li @click="navigate" @keypress.enter="navigate" role="link">About Us</li>
</router-link>

更多推荐

vue3中被抛弃的方法,过滤器和tag

本文发布于:2024-02-06 15:35:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749695.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   方法   tag

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!