java中的module是什么意思_Angular - 组件中module.id的含义是什么?
Update for (2017-03-13) :
刪除了所有提及的moduleId . “組件相對路徑”cookbook已刪除我們在我們推薦的SystemJS配置中添加了一個新的SystemJS插件(systemjs-angular-loader.js) . 此插件動態地將templateUrl和styleUrls中的“組件相對”路徑轉換為“絕對路徑” . 我們強烈建議您只編寫組件相對路徑 . 這是這些文檔中討論的唯一URL形式 . 您不再需要編寫@Component({moduleId:module.id}),也不應該 .
Definition:
moduleId?: string
@Component 注釋中的 moduleId 參數采用 string 值,即;
“包含組件的模塊的模塊ID . ”
CommonJS用法: module.id ,
SystemJS用法: __moduleName
Reason to use moduleId :
moduleId 用于解析樣式表和模板的相對路徑,如文檔中所述 .
包含組件的模塊的模塊ID . 需要能夠解析模板和樣式的相對URL . 在Dart中,這可以自動確定,不需要設置 . 在CommonJS中,始終可以將其設置為module.id .
我們可以通過設置@Component元數據的moduleId屬性來指定模板和樣式文件相對于組件類文件的位置
Example usage:
文件夾結構:
RootFolder
├── index.html
├── config.js
├── app
│ ├── components
│ │ ├── my.component.ts
│ │ ├── my.component.css
│ │ ├── my.component.html
Without module.id :
@Component({
selector: 'my-component',
templateUrl: 'app/components/my.component.html',
styleUrls: ['app/components/my.component.css']
})
With module.id :
tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
...
@Component({
moduleId: module.id,
selector: 'my-component',
templateUrl: 'my.component.html',
styleUrls: ['my.component.css']
})
總結
以上是生活随笔為你收集整理的java中的module是什么意思_Angular - 组件中module.id的含义是什么?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java动态变量名反射_Java动态性—
- 下一篇: mysql构建栋_【转载】这次拆库 应是