简体   繁体   English

单击在Vue-Chart.js中绘制在图表上的值时如何打开对话框

[英]How can I open the dialog when clicking the value that has been plot on chart in vue-chartjs

I'm trying to open a v-dialog when I click a point on a chart. 单击图表上的某个点时,我试图打开v-dialog I bound the dialog's v-model to this.dialog (a data property), but setting this.dialog to true doesn't open the dialog. 我将对话框的v-model绑定到this.dialog (数据属性),但是将this.dialog设置为true不会打开对话框。 When I check the value of the this.dialog , it is really true . 当我检查this.dialog的值时,确实是true Why doesn't the dialog open? 为什么对话框没有打开?

<line-chart
    :chart-data="datacollection"
    :options="optionscollection"
    />

this.optionscollection = {
  onClick: function(evt, item) {
    this.dialog = true;
  }
};

The onClick handler does not have its context bound properly, so this is not the Vue component instance there. onClick处理程序未正确绑定其上下文,因此this 不是 Vue组件实例。 Use an arrow function instead: 改用箭头功能

this.optionscollection = {
  onClick: (evt, item) => {
    this.dialog = true;
  }
};

在图表上编辑打开v对话框,单击

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM