1

I try like this:

<template>
    <button @click="checkout" class="btn btn-danger pull-right" :type="typeButton">
        Checkout
    </button> 
</template>
<script>
    export default {
        methods: {
            data() {
                return {
                    typeButton: 'submit'
                }
            },
            checkout(e) {
                this.typeButton = 'button'
                ...
            }
        },
    }
</script>

Which gives the following error:

[Vue warn]: Property or method "typeButton" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

How can I solve this problem?

1 Answer 1

2

Move your data(){} object out of your methods: {}

So, your export should look like this:

export default {
  data () {
    return {
      typeButton: 'submit'
    }
  },
  methods: {
    checkout(e) {
      this.typeButton = 'button'
    }
  },
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.