【发布时间】:2021-08-04 23:30:00
【问题描述】:
这是我尝试使用 Axios 在 ionic 5 中调用 API 的代码
import axios from "axios";
import {
IonCard,
IonCardContent,
IonCardSubtitle,
IonCardTitle
} from "@ionic/vue";
export default {
name: "Tab1",
components: {
IonCard,
IonCardContent,
IonCardSubtitle,
IonCardTitle
},
data() {
return { posts: [] };
},
created() {
axios.get("http://gautammenaria.com/wp-json/wp/v2/posts").then(response => {
this.posts = response.data;
});
}
};
得到这个错误(也按预期得到数据)
TS2339: 类型 '{ name: string; 上不存在属性 'posts'组件:{
不知道是什么
【问题讨论】:
-
如果您要使用打字稿,
export default Vue.extend({ })会更有意义。 -
你用的是哪个vue版本?
-
我正在使用 vue 3
标签: typescript vue.js ionic-framework vuejs3 ionic5