code is as follows, where the iviewui used by the form of the page
<Input v-model="search" placeholder="Enter something..." style="width: 300px" />
<Button type="primary" @click="handleSearch()"></Button>
<div ref="chartBar" style="height:300px;"></div>
mounted () {
this.$nextTick(() => {
this.getData()
})
},
methods: {
getData () {
this.$get( //axios
"data.json",//
{ keywords: this.search },//search""
response => {
this.barDataHandle(response.data)
}
)
},
barDataHandle (data) {
//echarts
this.chartBar("", this.$refs.chartBar, legendData, courses, seriesData)
},
chartBar (subtext, chartBar, legendData, xAxisData, seriesData) {
// domecharts
let bar = echarts.init(chartBar)
//
bar.setOption({
title: {
text: "",
subtext: subtext
},
legend: {
top: 30,
data: legendData
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow" // :"line" | "shadow"
}
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true
},
xAxis: [
{
type: "category",
data: xAxisData,
axisTick: {
alignWithLabel: true
}
}
],
yAxis: [
{
type: "value"
}
],
series: seriesData
})
},
handleSearch () {
//search
this.getData()
}
}
when you enter the page, get the data returned by the backend API. The echarts chart is displayed normally, as shown in the figure above.
after clicking search, the API passes the parameters of the search conditions to retrieve the data, but the echarts diagram is not re-rendered. What should I do?