我正在尝试在 Angular 项目中实现拖放 ( https://github.com/akserg/ng2-dnd )。
我的配置(ng -v
):
@angular/cli: 1.1.3
node: 6.10.1
os: win32 x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.3
@angular/compiler-cli: 4.2.4
@angular/language-service: 4.2.4
我的步骤:
- 创建新项目:
ng new myProject --style=sass
- 安装 ng2-dnd:
npm install ng2-dnd --save
- 在我的 NgModule 中导入 DndModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DndModule } from 'ng2-dnd';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DndModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
- 从node_modules导入style.css
完成此步骤后,我像在 github 上一样添加了一个模板,但没有结果。我只看到纯文本,即使没有样式。
我做错了什么?
最佳答案
你应该在 angular-cli.json 中导入样式
"styles": [
"../node_modules/ng2-dnd/style.css",
],
关于angular - ng2-dnd 与 Angular 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44727674/