我正在使用单选按钮选择“月份和年份”。但是我不确定如何绑定按钮的选择以显示我想要显示的图表。
//模板
<b-form-radio-group class="mr-3" id="radiosBtn" buttons button-variant="outline-secondary" v-model="selected" name="radiosBtn" :options="options"></b-form-radio-group>
</b-button-toolbar>
</b-col>
</b-row>
<main-chart-example id='Month' chartId="main-chart-01" class="chart-wrapper Month" style="height:300px;margin-top:40px;" height="300"></main-chart-example>
<main-chart-example2 id='Year' chartId="main-chart-02" class="chart-wrapper Year" style="height:300px;margin-top:40px;" height="300"></main-chart-example2>
//
data: function () {
return {
selected: 'Month',
options: [
{ text: 'Month', value: 'Month' },
{ text: 'Year', value: 'Year' }
],
答案 0 :(得分:0)
您可以向图表添加v-if
指令。因此您的聊天记录如下:
<main-chart-example
v-if="this.selected === 'Month'"
id='Month'
chartId="main-chart-01"
class="chart-wrapper Month"
style="height:300px;margin-top:40px;"
height="300">
</main-chart-example>
<main-chart-example2
v-if="this.selected === 'Year'"
id='Year'
chartId="main-chart-02"
class="chart-wrapper Year"
style="height:300px;margin-top:40px;"
height="300">
</main-chart-example2>