美文网首页
鸿蒙 app 开发 遇到的问题总结

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

作者: Fultom | 来源:发表于2024-05-15 09:31 被阅读0次

创建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>

相关文章

网友评论

      本文标题:鸿蒙 app 开发 遇到的问题总结

      本文链接:https://www.haomeiwen.com/subject/fbymfjtx.html