Home>Article>Web Front-end> Problem in passing value from parent component to child component echarts in Vue
Record the problem of echarts stepping on the trap
#Problem: When the parent component passes the value to the child component echarts, it is found that the child component obtains The props were empty. At first I thought the hook function was in the wrong place, but later I found that neither mounted nor created worked. When the data passed in the parent component data is defined, the child component displays normally
Cause: After investigation later, the N word was omitted here, and it was found that echarts passes the data during rendering
Solution Solution: Define a flag in the parent component, and then render the subcomponent after the data is obtained
//父组件... export default { name: 'device', data() { return { flag:false, piedata:{}, ... }, created(){ this.init() }, methods:{ init(){ axios.get('/static/mock/status/pie.json').then(this.getInfoSucc) }, getInfoSucc(res){ res = res.data; if(res.code ==0){ const values = res.values; this.piedata = values.piedata; this.flag = true } }
//子组件
Then the subcomponent will be displayed normally
This article explains There is a problem in passing values from the parent component to the child component echarts in Vue. For more related content, please pay attention to the PHP Chinese website.
Related recommendations:
Javascript strict mode detailed explanation
php related code analysis to implement login function
JavaScript related content explanation
The above is the detailed content of Problem in passing value from parent component to child component echarts in Vue. For more information, please follow other related articles on the PHP Chinese website!