小王的
小王的
  • 发布:2022-09-12 02:32
  • 更新:2022-09-12 02:32
  • 阅读:320

hbuilderx创建项目+vue2+typescript创建项目编译报错

分类:HBuilderX

官方配置> https://uniapp.dcloud.net.cn/tutorial/typescript-subject.html
项目配置

<script lang="ts">  
    import Vue from 'vue';  
    export default Vue.extend({  
        onLaunch: function():void {  
            console.log('App Launch')  
        },  
        onShow: function():void {  
            console.log('App Show')  
        },  
        onHide: function():void {  
            console.log('App Hide')  
        }  
    })  
</script>

02:29:35.265 [tsl] ERROR at App.vue:4
02:29:35.267 TS2769:No overload matches this call.
02:29:35.276 The last overload gave the following error.
02:29:35.277 Argument of type '{ onLaunch: () => void; onShow: () => void; onHide: () => void; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>'.
02:29:35.287 Object literal may only specify known properties, and 'onLaunch' does not exist in type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>'.

2022-09-12 02:32 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复