Tôi có một ứng dụng mà sử dụng bộ chọn portfolio-app
và có 2 stylesheets - '../app/styles/templateMobile.css', '../app/styles/templateOther.css'
Angular2 không tiêm mẫu CSS khi làm mới trang
Bây giờ khi tôi mở ứng dụng của tôi từ địa chỉ URL mặc định (localhost: 3000 ATM), các stylesheets được áp dụng đúng cách. Nhưng khi tôi đi đến một tuyến đường khác, và nhấn làm mới (F5), các kiểu mẫu không được áp dụng cho trang. Điều tương tự cũng xảy ra khi tôi bắt đầu trên một tuyến đường khác.
Không có thông báo lỗi trong bảng điều khiển.
Tôi đã thử nghiệm điều này trong firefox, chrome và safari, chế độ ẩn danh và xóa bộ nhớ cache của trình duyệt. Tôi cũng đã thử nghiệm trên một LG G2, iPhone, iPad và nhiều trình giả lập Android khác nhau (Nexus 9, Nexus 10, Galaxy Nexus). Tất cả thời gian kết quả là như nhau.
app.component:
import { Component } from 'angular2/core';
import {ViewEncapsulation} from 'angular2/core';
import { ROUTER_PROVIDERS, ROUTER_DIRECTIVES, RouteConfig } from 'angular2/router';
import { LandingComponent } from './landing.component';
import { PortfolioComponent } from './portfolio.component';
import { PagesService } from './pages.service';
@Component({
selector: 'portfolio-app',
templateUrl: '/app/views/template.html',
styleUrls: ['../app/styles/templateMobile.css', '../app/styles/templateOther.css'],
encapsulation: ViewEncapsulation.None,
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS, PagesService]
})
@RouteConfig([
{ path: '/landing', name: 'Landing', component: LandingComponent, useAsDefault: true },
{ path: '/portfolio', name: 'Portfolio', component: PortfolioComponent }
])
export class AppComponent {
landing = true;
portfolio = false;
changeMiniNavLanding = function() {
this.landing = true;
this.portfolio = false;
}
changeMiniNavPortfolio = function() {
this.landing = false;
this.portfolio = true;
}
}
main.ts:
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
bootstrap(AppComponent);
Nếu bạn cần thêm thông tin, xin vui lòng hỏi, hoặc duyệt trough kho gitHub. (tất cả các tệp có liên quan đều nằm trong thư mục ứng dụng).
Cảm ơn sự giúp đỡ.
Bạn có gặp bất kỳ lỗi nào trong bảng điều khiển trình duyệt không? –
Không, chỉ là thông báo chuẩn mà Angular 2 đang chạy trong chế độ phát triển –