在vue中子組件獲取一個來自父組件中的值并處理,使用ref注冊并在父組件中引用$refs獲取該組件實例,但是如果需要父組件傳遞給子組件數據再計算,該如何寫呢?代碼如下:export default{ data(){ return{ parentMsg:'hello!' } }, components:{ child:{ props:['inputMessage'], template:'<span>{{inputMessage}}</span>' }, 'child-secound':{ props:['inputMessage'], template:'<span>{{lowerCase}}</span>', computed:{ lowerCase(){ return this.$refs; // return this.inputMessage.toLowerCase(); } } } },}這里我想用從父組件獲取的數據inputMessage 在子組件中進行二次處理再輸出出來,使用到計算屬性,但是這里的return this.$refs卻是一個空對象,如何做到子組件在父組件中獲取到數據并二次修改再次修改然后輸出呢?
vuejs在子組件中如何調用計算屬性?
HUH函數
2018-10-12 14:15:53