Ng-zorro-antd: nz-date-picker 组件在 ng serve和ng build 正常,ng build --prod报错

Created on 4 Jun 2018  ·  15Comments  ·  Source: NG-ZORRO/ng-zorro-antd

Version

0.7.1

Environment

angular-cli: 1.7.4. ng-zorro-antd: 0.7.1
image

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-setup-qendx9?file=app/app.component.html

Steps to reproduce

ng build --prod

What is expected?

nz-date-picker 组件可以正常使用

What is actually happening?

报错:Cannot read property 'placeholder' of undefined
image

Other?

Doc

Most helpful comment

在app.module.ts下注册一下中文国际化,刚检查了一下文档中漏写了

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { AppComponent } from './app.component';
import { NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    FormsModule,
    NgZorroAntdModule.forRoot()
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
  providers   : [ { provide: NZ_I18N, useValue: zh_CN } ]
})
export class AppModule { }


All 15 comments

nz-date-picker 没有placeholder 这个Input,仔细看文档

这是我的代码,在ng serve 和 ng build 的时候都可以正常使用,只有在ng build --prod 时就出错了

在app.module.ts下注册一下中文国际化,刚检查了一下文档中漏写了

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { AppComponent } from './app.component';
import { NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    FormsModule,
    NgZorroAntdModule.forRoot()
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
  providers   : [ { provide: NZ_I18N, useValue: zh_CN } ]
})
export class AppModule { }


@vthinkxie 我也遇见了这个问题 nz-range-picker 这个组件上的nzPlaceHolder需要给一个数组提示文字,才能让这个组件在build的时候正常,可能是没有建立默认的提示文字数组? 看了下源码是需要读取nzPlaceHolder这个属性的index,在nz-range-picker下,如果给nzPlaceHolder一个字符串,他会读取字符串charAt的0和1位,其实就是读取的nzPlaceHolder[index]位置!这个组件可能存在一点小问题

@BerQin 组件初始化的时候没有默认注册中文的i18n,导致i18n模块读取placeholder的时候挂了,快速上手部分漏掉了注册中文i18n的部分。

@vthinkxie 同样是ng build --prod 报错
20180604155704
ng-zorro-antd 源码里面是
20180604160654
npm包里面是
20180604160959

@vthinkxie 不过我们当时检查了注册部分确认是注册了中文的i18n! 只有nz-range-picker 有这个问题,其他的都正常,那个错误是通过放入数组解决的,就没再就进一步跟进!多交流!我感觉之前的表格方式挺好用的,改版后,普通的table只能用正常的table标签了,但是没有了固定头部的功能,需要自己搞希望在完善完善表格!不然屏幕窄的时候不出横向滚动条,文字换行搞得一个字母一行很难受

@BerQin 仔细看文档,table是包含了之前全部功能的,除了data的input改了之外其他基本没有任何修改,源代码是基本没有改动的。

@cryle 注意看下自己的package-lock.json,你本地安装的不是0.7.1,是0.7.0

@vthinkxie 0.0 好的!不过我看了好多遍了,需要自己给设置一个nzScoll的X和Y 这个值在我们做宽表展示的时候是不确定宽度的! 需要他自动撑开!我在看看去!谢谢

@BerQin 自动撑开是css来完成的,之前也没有这个功能

td {white-space: nowrap;}

@vthinkxie 确定是0.7.1, 0.7.0没有这个问题
222
3

@cryle
https://unpkg.com/[email protected]/src/date-picker/abstract-picker.component.d.ts
https://unpkg.com/[email protected]/src/date-picker/month-picker.component.d.ts
0.7.1的npm包在线代码,这里总不会有问题吧,仔细对比一下,你截的npm包的图是0.7.0的

@vthinkxie 谢谢·,已解决。也许是yarn的bug,upgrade没有完全替换,删除重新安装就OK了

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings