使用buildOptimizer和aot

时间:2018-08-13 08:02:31

标签: build angular6

我的Angular 6项目将无法使用该命令进行构建;

ng build --prod --configuration=production  --base-href=/quickorder/

并给出错误;

ERROR in src\app\order-input\order-input.component.html(43,17): : Property 'number' does not exist on type 'OrderInputComponent'.
src\app\order-input\order-input.component.html(58,57): : Property 'autoCorrect' does not exist on type 'OrderInputComponent'.
src\app\order-input\order-input.component.html(58,19): : Property 'value' does not exist on type 'OrderInputComponent'.
src\app\order-input\order-input.component.html(72,19): : Property 'value' does not exist on type 'OrderInputComponent'.
src\app\order-input\order-input.component.html(82,19): : Property 'value' does not exist on type 'OrderInputComponent'.
src\app\order-input\order-input.component.html(112,31): : Property 'checked' does not exist on type 'OrderInputComponent'.
src\app\order-input\order-input.component.html(112,31): : Property 'checked' does not exist on type 'OrderInputComponent'.

这些似乎来自我的kendo-ui组件。

我的angular.json;

      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        }
      }
    },

但是,如果我将aot和buildOptimizer设置为false,则可以使用。这是Angular的问题,还是我做错了什么?

一些html;

        <label class="k-form-field required" for="product" style="width: 40%; display: inline-block">
            <span>Select Product</span>
            <kendo-autocomplete class="form-control" id="product" name="product" required validationMessage="Select Product"
            [popupSettings]="{width: 400}"
            style="width: 100%;" 
            [data]="listItems"
**Line 43-->[value]=number**
            [valueField]="'PackDescription'"
            [filterable]="true"
            [placeholder]="'e.g. Wheat or 25KG (3 character minimum)'"
            (valueChange)="valueChange($event)"
            (filterChange)="filterChange($event)"
            [(ngModel)]="product" 
            [ngModelOptions]="{standalone: true}">
          </kendo-autocomplete><span class="k-invalid-msg" data-for="product"></span>
        </label>
        &nbsp;
        <label class="k-form-field required" for="quantities" style="display: inline-block">
            <span>Quantity</span>
            <!-- <input style="width: 150px" type="number" class="form-control" [(ngModel)]="quantity" name="quantities"  id="quantities" required validationMessage="Select Quantity"> -->
            <kendo-numerictextbox
              [value]="value" [min]="1" [max]="200" [autoCorrect]="autoCorrect"
              [(ngModel)]="quantity"
              [ngModelOptions]="{standalone: true}">
            </kendo-numerictextbox>
            <span class="k-invalid-msg" data-for="quantities"></span>             
        </label>

Thr .ts;

export class OrderInputComponent implements OnInit {

  MINFILTERLENGTH: number = 3;

  ref: string;
  name: string;
  repRef: string;
  allData: any[];
  xrefAddress = [];
  addressListItems: Array<Object> = [];
  listItems: Array<Object> = [];
  selectedItem: Object;
  orderLines: Array<Object> = [];
  total: number;
  addressNumber: string;
  productNumber: string;
  defaultAddressItem:  { name: string, number: number } = {name: "Select Address...", number: null};
  newOrderLines: Array<Object> = [];
  tradingpartner: string;
  product: string;
  productRef: string;
  productDesc: string;
  quantity: number;
  price: number;
  selectedValue: number;

  orderRef: string = null;
  orderError: string = null;

  fd: Date;
  td: Date;
  fromDate: string;
  toDate: string;
  collection: boolean;
  debug: boolean = false;
  comments: string;
  public events: string[] = [];

  constructor( private user: UserService,
               private router:Router,
               private orders: OrdersService,
               private route: ActivatedRoute,
               private productXref: ProductXrefService,
               private addressXref: AddressXrefService,
               private intl: IntlService,
               private createOrderService: CreateOrderService,
               private globalsService: GlobalsService,
               private location: Location,
               private ngxXml2jsonService: NgxXml2jsonService,
               private localStorageService: LocalStorageService) {

在此先感谢您的帮助,

标记。

P.S。我应该补充一点ng服务和ng构建工作正常。

1 个答案:

答案 0 :(得分:1)

我不知道为什么,但是有时使用kendo控件,添加或删除[]可以帮助您解决此错误:

autoCorrect =“ autoCorrect”代替[autoCorrect] =“ autoCorrect”

希望这会有所帮助!