父组件
<template>
<bottomLeft
:type=sensorType
:sendData="data" />
<button @click='handleData'>点击按钮</button>
</template>
<script>
export default {
data () {
return {
sensorType: 'A',
data: {}
}
},
methods: {
handleData () {
this.$axios({
method:'get',
url:'api'
}).then((res) =>{
this.data = res.data
}).catch((err) =>
console.log(err)
})
}
}
}
</script>
子组件
template
<linegraph
:options="ViewData"
></linegraph>
script
data () {
return {
ViewData: {}
}
},
props: ['type', 'data'],
watch: {
data () {
this.ViewData = this.data
},
deep: true
}