在上一小節我們已經完成了關于三層架構的搭建,接下來我們來實現在三層架構中的導入依賴,將他們相互聯系起來。
第一步:在features產品定制層中,對其中所有的動態共享包導入依賴,示例features>my>oh-package.json5文件中
導入依賴"basic": "file:../../commons/basic"
示例代碼如下:
{"name": "phone","version": "1.0.0","description": "Please describe the basic information.","main": "","author": "","license": "","dependencies": {"basic": "file:../../commons/basic"}
}
全部按照上面的示例導入依賴?
?第二步:在products產品定制層,products>phone>oh-package.json5文件里面
?導入依賴公共能力層依賴
"basic": "file:../../commons/basic"
示例代碼如下:
{"name": "phone","version": "1.0.0","description": "Please describe the basic information.","main": "","author": "","license": "","dependencies": {"basic": "file:../../commons/basic"}
}
?導入依賴產品定制層依賴(如果我們產品定制層只有my)
"my": "file:../../features/my"
示例代碼如下:
{"name": "phone","version": "1.0.0","description": "Please describe the basic information.","main": "","author": "","license": "","dependencies": {"basic": "file:../../commons/basic","my": "file:../../features/my"}
}
完成全部依賴導入,我們的三層架構之間就有了聯系。2/3完成