gpt4 book ai didi

typescript - VS angular2 更改不会在浏览器上更新

转载 作者:太空狗 更新时间:2023-10-29 17:13:51 26 4
gpt4 key购买 nike

我开始使用 Angular2,当我第一次尝试运行我的项目时,它成功了。问题是我正在按照教程进行操作,但是当我运行它时,任何更改都不会显示在任何浏览器上!

这是我的“app.component.ts”:

import {Component} from 'angular2/core';

@Component({
selector: 'my-app',
template: '<h1>Testing...</h1>'
})

export class AppComponent {
title = 'Tour of Heroes';
}

这在任何浏览器上都显示正常,但是当我更改为:

import {Component} from 'angular2/core';

@Component({
selector: 'my-app',
template: '<h1>{{title}}</h1>'
})

export class AppComponent {
title = 'Tour of Heroes';
}

它继续显示“正在测试...”。它应该显示“英雄之旅”。为什么?

我所有的其他文件都和教程一样!

Ps.: 我安装了“node和npm”!

[@PankajParkar 提到需要编辑“System.config”]这就是我在 index.html 上的内容,与 Angular2 教程中的内容相同

<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/main').then(null, console.error.bind(console));
</script>

最佳答案

这个问题非常令人沮丧,但我就是这样解决的。

在浏览器中按 F12 调出开发者工具。如下所示禁用缓存

enter image description here

其次,我必须在 web.config 中的标记上方添加此部分以禁用缓存

<location path="app">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache"/>
</staticContent>
</system.webServer>
</location>

关于typescript - VS angular2 更改不会在浏览器上更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36669222/

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