假设我有一个Javascript数组,如下所示:
["Element 1","Element 2","Element 3",...]; // with close to a hundred elements.
Run Code Online (Sandbox Code Playgroud)
什么方法适合将数组块(拆分)到许多较小的数组中,比如最多10个元素?
我无法找到一种方法来选择不同的选项来渲染v-for中的文本.是否可能或者我是否需要以不同的方式构造逻辑以执行类似下面的代码?
<template>
<ul v-show="showNotifications">
<li v-for="notification in notifications">
// if notification.type = 'friend request'
New friend request from {{ notification.name }}
// else
New notification from {{ notification.name }}
</li>
</ul>
</template>
Run Code Online (Sandbox Code Playgroud)
通知是一组对象,其中包含名称和通知类型等数据.