4

I have a checkbox component defined like so:

let checkbox = this.$createElement(VCheckbox, {
    props: {
        hideDetails: true
    }
});

In my code I can get a reference to this component. In other words I have access to this checkbox variable. What I want is to set property programmatically. By property I mean this part of the component:

props: {
    hideDetails: true
}

What I want is to set indeterminate to true. Something like:

checkbox.setProperty('indeterminate', true);

But I'm unable to find in documenation anything related to my problem. So, how can I implement this?

Jacobian
  • 10,122
  • 29
  • 128
  • 221

2 Answers2

4

You can create a dynamic variable in your data scope :

data: function() {
  return {
    stateDetails: true
  };
}

Then use it in your props :

props: {
  hideDetails: this.stateDetails
}

And now you can change the value like that :

this.stateDetails = true / false
John
  • 4,711
  • 9
  • 51
  • 101
1

You could try

let checkbox = this.$createElement(VCheckbox, {
    ref:"refToElement",
    props: {
        hideDetails: true
    }
});
    this.$refs.refToElement.$el.setProperty('indeterminate', true);
Abdulla Thanseeh
  • 9,438
  • 3
  • 11
  • 17