我在ionic 2中使用此简单代码:
<button (click)="takePicture()" >Take a pic!</button>
<img [src]="url || '//:0'">
Run Code Online (Sandbox Code Playgroud)
这是我的Typescript页面:
import {Page} from "ionic-framework/ionic";
@Page({
templateUrl: 'build/pages/smartscan/smartScan.html'
}
)
export class SmartScan {
public url:string;
constructor() {
console.log("Starting SmartScan page ...");
}
public takePicture() {
console.log("Going to take a pic ...");
navigator.camera.getPicture( (imageURI) => {
this.url = imageURI;
console.log("URI of the picture taken is : "+this.url);
console.log(JSON.stringify(this));
//var image = document.getElementById('myImage');
//image.src = imageURI;
}, function (err) {
console.log(JSON.stringify(err));
}, {});
/* this.url = "http://maison-cresci.fr/uploads/images/nice_cresci_slide_environnement_003.jpg";
*/
}
} …
Run Code Online (Sandbox Code Playgroud) “type”是一个语言关键字,但我需要将它用作结构中的属性名称,例如:
type Message struct{
type string
}
Run Code Online (Sandbox Code Playgroud)
我的 IDE 发现错误行 2