been banging my head once more.
I'm surprised I haven't seen a similar question here on SOF, but it's really weird. This code WAS working, but I moved into a standalone component to be used on multiple pages. This is the error I'm getting when I go to the page:
handler.call is not a function
I know for a fact it is this component because if I remove the component from the page, there is no error and runs fine. The component calls no functions and has no functions in the script. I have no idea what is going on.
and in the console log, there isn't much help either:
TypeError: "handler.call is not a function"
    NuxtJS 21
    invokeWithErrorHandling
    callHook
    insert
    invokeInsertHook
    patch
    _update
    updateComponent
    get
    Watcher
    mountComponent
    $mount
    mount
    _callee5$
    tryCatch
    invoke
    method
    asyncGeneratorStep
    _next
    run
    notify
    flush
This is the very simple component source code:
<template>
    <div>
        <button v-if="can_edit" class='btn-blue'> Edit </button>
        <div v-for="card in cards" class='my-credit-card' v-bind:key="card.id">
            <h5>{{card.name}}</h5>
            <h5 class='mt-0'>•••• •••• •••• {{card.last4}}</h5>
            <p class='small'>Exp. {{card.expiration}}</p>
        </div>
        <div v-if="cards.length == 0">
            <p class='subtle'>
                Your saved payment methods will display here once you send your first card!
            </p>
        </div>
        <a v-if="(can_add && cards.length > 0)" href="/add-card" class='action'> + Add New Card </a>
    </div>
</template>
<script>
export default {
    data : function(){
        return {
            cards : [
                {
                    id: 1,
                    name: "Lisa Smith",
                    last4: "4231",
                    expiration: "12/2022"
                },
                {
                    id: 2,
                    name: "John Smith",
                    last4: "1234",
                    expiration: "11/2023"
                },
            ],
        };
    },
    props : {
        can_add : {
            default : true,
            type: Boolean,
        },
        can_edit : {
            default : true,
            type: Boolean,
        },
    },
    mounted : {
        // fetch cards
    },
}
</script>
and this is how I'm importing the component:
<template>
    <section class='container'>
        <h1>My Credit Cards</h1>
        <mycards :can_add="true" :can_edit="true"></mycards>
    </section>
</template>
<script>
import mycards from '~/components/my_cards.vue';
export default {
    data : function(){
        return {
            test : 1,
        };
    },
    components : {
        mycards,
    },
}
</script>
                This:
mounted : {
    // fetch cards
},
Should be:
mounted () {
    // fetch cards
},
You're setting your mounted hook to an object, which won't have a call method on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With