使用环境:

Angular CLI: 1.7.4
Node: 8.11.1

执行:ng new cloud --routing --style scss --skip-install
生成文件上传到github上 :步骤如下:
登录github
新建仓储
在自己本地文件内

git init 
git status
git add .  
git commit -m "github测试"
git remote add origin github仓储地址  // eg:https://github.com/lkpTomorrow/cloud.git
git push -u origin master  

项目就上去了

过程中需要输入github的账号和密码验证
在文件夹内部使用这些命令

在package.json的"devDependencies"中增加
“@angular/cdk”: “5.2.0”, // 在安装前加上这行,我放在cli前面
“date-fns”: “^1.29.0”, // 可以在报错的时候再行安装,位置随意

npm i // 安装包
装完成后,通过npm start启动项目,查看是否运行正常!

添加antd的文件(我们放在项目中,便于修改源码):
github中搜索ng-zorro-antd,查看releases,找到对应的版本(angular对应的antd的版本)(cli为1.7.4版本,那么我用antd 0.7.x版本)

我使用的是0.7.0版本的antd,下载后解压,components中就是对应的源码(我们可能会修改源码,所以放到了项目中)
把components放在app目录下,文件名字为ngdesign
antd最后会export一个模块:NgZorroAntdModule

在app.module中引入该模块NgZorroAntdModule.forRoot();
重新编译
在ngdesign的组件中demo文件缺少ng-zorro-antd模块
删除demo文件,没用的

zhuyi :
修改了angular-cli.json文件,需要重新编译,要不然不会执行

在这里增加了antd的less文件,引入antd的样式
“styles”: [
“styles.scss”,
“app/ngdesign/ng-zorro-antd.less”
],
其中:app开头,不用…/src等

在main.ts中:
if生产环境:这些函数不执行
window.console.log=function(){};
window.console.info=function(){};
window.console.warn=function(){};
window.console.error=function(){};
window.console.debug=function(){};

在index.html中:

就是app.component.ts的selector

app.routing文件:内部文件注释,改为:
export const routes: Routes = [
{path: ‘’, redirectTo: ‘auth’, pathMatch: ‘full’},
{path: ‘**’, redirectTo: ‘auth’},
];
export const routing: ModuleWithProviders = RouterModule.forRoot(routes, {useHash: false});

app.module中引入routing(imports)

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐