鸿蒙 app 开发 遇到的问题总结

创建mudole ets/index 添加export导出 export { HomePage } from './pages/HomePage'
报错 :Cannot find module 'home' or its corresponding type declarations. <tsCheck>

module.json5
{
  "module": {
    "name": "home",
    "type": "shared",
    "description": "$string:shared_desc",
    "deviceTypes": [
      "phone",
      "tablet"
    ],
    "deliveryWithInstall": true,
    "pages": "$profile:main_pages"
  }
}
hvigorfile.ts
module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks

build-profile.json5
"modules": [
    {
      "name": "entry",
      "srcPath": "./entry",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        }
      ]
    },
    {
      "name": "home",
      "srcPath": "./home",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        }
      ]
    }
  ]
oh-package.json5 

{
  "name": "entry",
  "version": "1.0.0",
  "description": "Please describe the basic information.",
  "main": "",
  "author": "",
  "license": "",
  "dependencies": {
    "home": "file:../home"
  }
}

import { HomePage } from 'home' 时先去entry模块下的oh-package.json5 下去找对应模块
需要添加"common": "file:../home" 不然会报错Cannot find module 'home' or its corresponding type declarations. <tsCheck>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容