我有一個帶有年份的簡單下拉列表的圖表,我需要在用戶修改年份時傳遞年份,以便圖表顯示當年的數據。例如,當我嘗試從這個方法訪問參數時,我得到的都是未定義的:fetchBarChartData({ anio, sort }) { var self = this; console.log(anio); fetch("https://demo8358110.mockable.io/year/" + this.anio) // insert your api call here .then(function(response) { var r = response.json(); return r; }) .then(function(data) { self.values = data.values; self.valuesline = data.valuesline; self.loaded = true; });https://demo8358110.mockable.io/year/undefined編輯:我添加了一個示例https://codesandbox.io/s/vue-template-x4z7b
無法將數據從模型傳遞到 Vue.js 中的方法
慕森王
2021-09-30 15:19:54