因此,我嘗試在我的 vue 應用程序中使用 Axios 從 URL 獲取數據,但它一直返回以下錯誤: Arrow function should not return assignment完整的錯誤輸出:error: Arrow function should not return assignment (no-return-assign) at src\components\navbar.vue:123:13: 121 | created() { 122 | axios.get('http://ip-api.com/json')> 123 | .then((response) => (this.countryCode = response.countryCode)); | ^ 124 | }, 125 | }; 126 | </script>1 error found.我的代碼:<script>import axios from 'axios';export default { name: 'navbarr', data() { return { countryCode: null, country: '', countries: [ { value: 'INT' }, { value: 'UK' }, { value: 'PT' }, { value: 'US' }, { value: 'FR' }, { value: 'DE' }, { value: 'IT' }, { value: 'ES' }, { value: 'IE' }, ], }; }, created() { axios.get('http://ip-api.com/json') .then((response) => (this.countryCode = response.countryCode)); },};</script>我正在關注官方示例,但我無法理解這里有什么問題!
使用axios獲取api數據時箭頭函數不應該返回賦值(Vue.js 2)
慕森卡
2022-11-03 11:02:47