【问题标题】:Why do I get Unexpected Token , error?为什么我得到 Unexpected Token ,错误?
【发布时间】:2017-12-06 22:32:02
【问题描述】:

我正在 Ionic 框架上为移动设备开发应用程序。所以我刚刚在我的安卓设备上安装了“离子白屏死机”。我得到了意外的令牌,错误。好的,我在谷歌浏览器中打开了检查器,我得到了什么

Picture 1

如您所见,main.js 文件中有错误。我找到了这个文件。它位于 www/build 文件夹中。所以这个 Main.js 是构建 android 应用程序所必需的。 好的,所以我无法编辑此文件,因为当我再次尝试构建应用程序时,我的所有编辑都会撤消。我可以在没有编辑的情况下看到原始文件。为什么会这样?

!!我使用 libary 进行图像编辑 LowPoly -> Link

triangle.html

<ion-header>

    <ion-navbar>
    <ion-title>Trianglify</ion-title>
    </ion-navbar>

</ion-header>


<ion-content class="triangle" text-center>

<button ion-button block outline (click)="takePicture()">Take a picture</button><br>
<button ion-button color="secondary" block outline style="position: absolute; bottom: 5px;" (click)="transformPHToTriangle(base64Image);">Transform</button>

<img [src]="base64Image" *ngIf="base64Image">
</ion-content>

三角形.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Camera, CameraOptions } from '@ionic-native/camera';
import  LowPoly from 'lowpoly';

@IonicPage()

@Component({
    selector: 'page-triangle',
    templateUrl: 'triangle.html',
})

export class TrianglePage {

    public base64Image: string = './home_img/portrait.jpg';

    constructor(private camera: Camera, public navCtrl: NavController,         public navParams: NavParams) {}

    ionViewDidLoad() {
        console.log('ionViewDidLoad TrianglePage');
    }

    takePicture() {
        this.camera.getPicture({
        destinationType: this.camera.DestinationType.DATA_URL,
        targetWidth: 1000,
        targetHeight: 1000
        }).then((imageData) => {
        this.base64Image = "data:image/jpeg;base64," + imageData;
        }, (err) => {
        console.log(err);
        });
    }

transformPHToTriangle(photo) {
    new LowPoly(photo, {EDGE_DETECT_VALUE:80, 
    POINT_RATE:0.075, 
    POINT_MAX_NUM:3500, 
    BLUR_SIZE:2, 
    EDGE_SIZE:8, 
    PIXEL_LIMIT: 350000}).init().then((data) => {
    this.base64Image = data;
    });
    }
}

【问题讨论】:

  • 当您可以将其放在帖子本身时,为什么要链接到图像?
  • 请贴出代码。
  • 另外,请张贴您的代码minimal reproducible example
  • @Bergi,代码已发布,抱歉

标签: javascript typescript ionic-framework


【解决方案1】:

库希望你通过 babel 传递它。请参阅文档:https://github.com/jrainlau/LowPolifier#usage

修复

使用babel-loader

更多

https://github.com/babel/babel-loader

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-25
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多