首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >属性不存在- Axios & TS

属性不存在- Axios & TS
EN

Stack Overflow用户
提问于 2021-06-28 10:42:45
回答 2查看 270关注 0票数 0

我试图从带有Vue3 & TypeScript中axios的Google电子表格中获取数据。

这是我第一次使用vue3而不是Vue2。

我有一个错误:属性'items‘在'BiblioAll'类型上不存在

这是我的密码

代码语言:javascript
复制
<template>
  /// My template
</template>

<script lang="ts">
import { Vue } from "vue-class-component";

export default class BiblioAll extends Vue {
    data () {
        return{
            items: {} as any
        }
    }
    created(){
            this.axios.get("https://spreadsheets.google.com/feeds/list/1ZTO87yKX4NkQ7I641eL01IcGzlnugdK_Nkou5cSy1kQ/1/public/values?alt=json")
            .then(response => (this.items = response))
        }
        
    }
}
    
</script>

<style scoped>
     /// Styles
</style>

有人知道怎么解决吗?

谢谢

EN

回答 2

Stack Overflow用户

发布于 2021-06-28 10:46:00

Vue 3很好地支持类型记录,所以我建议不要使用vue类组件,只需使用defineComponent创建组件就可以得到类型推断,如下所示:

代码语言:javascript
复制
<template>
  /// My template
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent( {
    data () {
        return{
            items: {} as any
        }
    }, 
    created(){
            this.axios.get("https://spreadsheets.google.com/feeds/list/1ZTO87yKX4NkQ7I641eL01IcGzlnugdK_Nkou5cSy1kQ/1/public/values?alt=json")
            .then(response => (this.items = response))
        }
        
    }
})
    
</script>

<style scoped>
     /// Styles
</style>
票数 2
EN

Stack Overflow用户

发布于 2021-06-28 10:45:31

items类中定义BiblioAll

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68161947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档