【问题标题】:Angular2 template field issue [duplicate]Angular2模板字段问题[重复]
【发布时间】:2016-10-08 11:09:05
【问题描述】:

Angular2 中的模板字段出现间距问题

这是我的代码。

@Component({
    selector: 'my-component',
    template: ' <h1 class="test">
                   Angular 2 Template    
                </h1>',
    styleUrls: ['./assets/style.css']
})

这不起作用

@Component({
    selector: 'my-component',
    template: ' <h1 class="test">Angular 2 Template</h1>',
    styleUrls: ['./assets/style.css']
})

这行得通

【问题讨论】:

    标签: angular


    【解决方案1】:

    那是因为你应该为template literals 使用 ES6 反引号“`”:

    Component({
            selector: 'my-component',
            template: ` <h1 class="test">
                           Angular 2 Template    
                        </h1>`,
            styleUrls: ['./assets/style.css']
        })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 2016-09-20
      • 2017-05-24
      • 2016-02-21
      相关资源
      最近更新 更多