模块依赖
Entry依赖Feature
- 添加依赖信息:
Entry模块的oh-package.json5文件的dependencies部分,添加对Feature模块的依赖:
"@ohos/auth": "file:../auth",
或
"auth": "file:../auth",
- 添加多模块运行支持:
打开编辑配置 ![编辑配置](https://i-blog.csdnimg.cn/blog_migrate/07219605da9edc892b9a0f812283fdcd.png)
左侧选择Entry,右侧选择Deploy Multi Hap,将Deploy Multi Hap Packages打勾,然后再下面的下拉菜单中将Feature模块打勾,然后点击确认。 ![](https://i-blog.csdnimg.cn/blog_migrate/16f0f1c23ea430e59755cb4812250527.png)
- 页面导航
使用系统router导航,url改为:@bundle:<bundleName>/<moduleName>/<页面相对路径,以Main文件夹为起点>
,例如:@bundle:com.lzx.jokes/auth/ets/pages/LoginPage
- 导出类、组件等
// library/src/main/ets/index.ets 一定要在index.ets文件中按照如下格式导出,否则其他模块无法引用
export { MyTitleBar } from './components/MyTitleBar'
export { Log, add, minus } from './utils/test'
转自:https://www.cnblogs.com/lizhenxin/p/17883341.html