gpt4 book ai didi

angular - 基本文件结构误解

转载 作者:太空狗 更新时间:2023-10-29 17:59:40 24 4
gpt4 key购买 nike

因此,我有一个 app 文件夹,其中包含我的组件及其基础模板。我的问题是,在组件的字符串中,我在 @Component 装饰器中指定了模板的位置,例如。

@Component({
selector: "add-site-view",
templateUrl:"app/add-site.template.html"
})

,为什么我需要明确指定“app/template.html”并且不能使用“./”而不是“app/”?

最佳答案

@Component URL(templateUrlstyleUrls)是相对于 index.html 解析的,而不是.ts 文件。这就是为什么您必须指定完整路径(从 index.html 开始)。

你可以做的是使用官方的 angular-cli https://github.com/angular/angular-cli

他们使用 Webpack 并且基本上 @Component URL 是相对于 .ts 文件的,如果那是你需要的话。

关于angular - 基本文件结构误解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39847189/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com