过滤器和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
发布评论