模块依赖
Entry依赖Feature
- 添加依赖信息:
Entry模块的oh-package.json5文件的dependencies部分,添加对Feature模块的依赖:
"@ohos/auth": "file:../auth",
或
"auth": "file:../auth",
- 添加多模块运行支持:
打开编辑配置
![编辑配置](https://img2023.cnblogs.com/blog/788034/202312/788034-20231207162835968-914125306.png)
左侧选择Entry,右侧选择Deploy Multi Hap,将Deploy Multi Hap Packages打勾,然后再下面的下拉菜单中将Feature模块打勾,然后点击确认。
![](https://img2023.cnblogs.com/blog/788034/202312/788034-20231207163131228-1138321664.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'