最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set component property programmatically in Vuetify component - Stack Overflow

programmeradmin2浏览0评论

I have a checkbox ponent defined like so:

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

In my code I can get a reference to this ponent. 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 ponent:

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?

I have a checkbox ponent defined like so:

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

In my code I can get a reference to this ponent. 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 ponent:

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?

Share Improve this question asked Apr 18, 2019 at 12:26 JacobianJacobian 10.9k32 gold badges140 silver badges233 bronze badges 11
  • this.hideDetails = true is not working ? – John Commented Apr 18, 2019 at 12:42
  • No, it is not.. – Jacobian Commented Apr 18, 2019 at 12:45
  • So why you don't create a dynamic variable in data ? hideDetails: this.state – John Commented Apr 18, 2019 at 12:52
  • @John. Nice tip, I will check it in a minute. – Jacobian Commented Apr 18, 2019 at 12:55
  • Did you solve your problem ? – John Commented Apr 18, 2019 at 14:07
 |  Show 6 more ments

2 Answers 2

Reset to default 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

You could try

let checkbox = this.$createElement(VCheckbox, {
    ref:"refToElement",
    props: {
        hideDetails: true
    }
});
    this.$refs.refToElement.$el.setProperty('indeterminate', true);
发布评论

评论列表(0)

  1. 暂无评论