单引号,双引号的使用 :
@Component{
select:'my-app',
template:`
<h2>hello</h2>
`,
style:`
h2{
color:red;
}
`
}
在使用到相关标签语法的使用就不能使用单引号,双引号了,使用的ESC键的下面这个符号’’,称之为反引号,它是与单引号不同的,
还有一处使用的地方:
export class AppComponent{
private url='api/index';
getSomething(id:number):Promise<some>{
const urlSome = `${this.url}/${id}`;
return this.http.get(urlSome)
.toPromsise()
.then(...)
.catch(...)
}
}
也就是在调用内部变量时,注意使用细节。
刚初学,这个问题浪费好久,才注意到然后改用这样:
const urlSome = '${'+this.url+'}/${'+id+'}';
这里使用的是单引号!
恩恩,这样是可以的,选择使用那个按自己习惯来。