关于uniapp默认组件 类型冲突的解决方案

150 阅读1分钟

在使用uniapp+ts开发小程序的时候会遇到各种各样的类型错误或冲突.

  1. 在使用uniapp默认button组件,type类型报错,不能将类型'default'分配给button的错误

image.png

解决方案: 在tsconfig.json 中,添加 vueCompilerOptions

{
        "compilerOptions":{
            ...
        }
        ...
        "vueCompilerOptions": {
            "nativeTags": ["block", "component", "template", "slot"]
        }
    }