[Vuejs]-Interact with component in component

0👍

Couple of ways you could do it, I think the easiest is to use v-ref:

<button-component v-ref:loading-button></button-component>

    methods: {
      buttonClick() {
        this.$refs.loadingButton.loading = true;
      }
    }

Or you could add a loading property to the parent and sync it:

<button-component :loading.sync="loading"></button-component>

    data:{
        loading: false,
    },
    methods: {
      buttonClick() {
        this.loading = true;
      }
    }
👤Jeff

Leave a comment