[Vuejs]-How send comment.id to computed in vuejs?

0👍

Well, as user8672473 said, it’s not really possible. If you insist on using a computed property, you can make this portion of your code into a component:

       <div id="comment">
            <img class="userimg" :src="userimg" alt="">
        </div>

reworked parent component:

<template>
    <div>
        <div id="comments" v-for="(comment,i) in allcomments">

            <comment-component :comment="comment">
            </comment-component>
        </div>


    </div>
</template>

And this will be your comment-component:

    <template>
       <div id="comment.id">
           <img class="userImg" :src="userImg" alt="">
       <div>
    </template>

    <script>
    export default {
        props: {
            comment: {
                type: Object
            }
        },
        computed: {
            userImg({ comment }) {
                return comment.id
            }
        }
    }
    </script>

Leave a comment