当前位置:网站首页>Filter the numbers and pick out even numbers from several numbers

Filter the numbers and pick out even numbers from several numbers

2022-07-05 06:17:00 hamimelon2020

<template>
<div>
   <li v-for="n in evenNumbers" :key="n">{
    {
     n }}</li>
</div>
</template>

<script>
export default {
    
    name: 'item',
    data() {
    
        return {
    
            numbers: [ 1, 2, 3, 4, 5 ]
            }
            },
            computed: {
    
                evenNumbers() {
    
                    return this.numbers.filter(number => number % 2 === 0)
                    }
                    }
                    }
</script>

原网站

版权声明
本文为[hamimelon2020]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140617451561.html