Home>Article>Web Front-end> Problem in passing value from parent component to child component echarts in Vue

Problem in passing value from parent component to child component echarts in Vue

jacklove
jacklove Original
2018-06-11 22:21:09 4222browse

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
Problem in passing value from parent component to child component echarts in Vue

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn