父元件
先在父元件引入子元件
import liChart from './dashboard/liChart';
components: { pieChart,linesChart,piesChart,piChart,liChart },
<div class="block">
<el-date-picker
v-model="month"
type="month"
placeholder="選擇月"
value-format="MM"
@change="getSTime">
</el-date-picker>
</div>
<li-Chart :msg ="this.month" >
</li-Chart>
getSTime(val) {
this.month = val
console.log('222',this.month)
},
子元件通過props接受參數
props: {
msg:{
type: String,
}
}
watch: {
msg(newval,oldval){
this.msg = newval
console.log(333,this.msg)
}
},