我已经在2017年的MS Visual Studio社区中使用Ionic 2已经有一段时间了.在Visual Studio Market中,可以下载并使用用于VS的插件Ionic 2 Templates.
它就像点击一样简单:
新建项目> TypeScript>移动应用程序> Ionic 2 - 空白
但是我找不到Ionic 3的模板.(似乎尚未发布)
知道如何手动将Ionic 3添加到Visual Studio吗?
谢谢!
我需要将tappable指令添加到ion-card自定义组件内的组件.我用的@Input() myInputBool是:
<ng-container *ngIf="myInputBool">
<ion-card tappable>
<ng-container render="myContent"></ng-container>
</ion-card>
</ng-container>
<ng-container *ngIf="!myInputBool">
<ion-card tappable>
<ng-container render="myContent"></ng-container>
</ion-card>
</ng-container>
<ng-container #myContent>
This is my content
</ng-container>
Run Code Online (Sandbox Code Playgroud)
当然它不起作用,因为没有"渲染"选项.到目前为止,我的解决方法是在ng-container中添加一个不存在的变量
<ng-container *ngIf="thisVariableDoesNotExist else myContent"> </ng-container>
Run Code Online (Sandbox Code Playgroud)
但它感觉很糟糕和黑客.有更好的方法吗?
我正在将paytm集成到angular 4中。paytm插件已成功添加到project中,但是我不知道如何在ts文件中导入paytm插件。并调用java文件文件功能。
请帮助我...这是我的代码
import { Nav, Platform } from 'ionic-angular';
import { Component, OnInit } from '@angular/core';
import { NavController } from 'ionic-angular';
import {} from 'jasmine';
import {LoginPage} from "../login/login";
import {SignUpPage} from "../signup/signup";
import {HomePage} from "../home/home";
import { Paytm } from '@ionic-paytm/paytm';
@Component({
selector: 'page-apphome',
templateUrl: 'apphome.html'
})
export class AppHomePage implements OnInit {
constructor(public navCtrl: NavController ,public paytm:Paytm) {}
ngOnInit(){
window.plugins.paytm.startPayment("526", "25862", "abc@gmail.com",
"777777777", "25", successCallback, failureCallback);
var userids=window.localStorage.getItem('userid');
//alert(userids);
if(userids!= null)
{
this.navCtrl.push(HomePage);
}
} …Run Code Online (Sandbox Code Playgroud) 我正面临ionic3应用中的问题.
让我详细描述一下我的情况:实际上我需要离线支持我的离子应用程序.所以每当我调用API时,我都会将数据存储到本地存储中.并将图像从api下载到我的本地目录.这样当我无法从本地资源获得互联网时,我可以获取数据和图像.
我使用这个插件将图像从服务器下载到本地:https: //ionicframework.com/docs/native/file-transfer/
如果我运行以下命令它工作正常:
ionic cordova run android
Run Code Online (Sandbox Code Playgroud)
但是当我运行以下命令时,它无法正常工作:
ionic cordova run android --prod
Run Code Online (Sandbox Code Playgroud)
代码:
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
constructor(private transfer: FileTransfer, private file: File) { }
const fileTransfer: FileTransferObject = this.transfer.create();
download() {
const url = 'http://www.example.com/file.pdf';
fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
Run Code Online (Sandbox Code Playgroud)
我没有从控制台收到任何错误或问题.所以我不知道我错过了什么.还可以很好地配置本地存储.所以许可不是问题.
我想使用FormData将图像上传到我的后端,但由于Ionic DEVAPP和Ionic VIEW不支持文件,文件传输和文件上传插件,我只需要使用Angular Http或HttpClient.
当使用DestinationType.FILE_URI时,我可以从文件中获取内部URL并将其显示在img对象上,但是我无法在没有本机文件,文件路径和文件传输插件的情况下从此URL创建一个打字稿文件对象.
getImage() {
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
}
this.camera.getPicture(options).then((imageData) => {
this.imageURI = this.sanitizer.bypassSecurityTrustUrl(imageData)
}, (err) => {
console.log(err)
this.presentToast(err)
})
Run Code Online (Sandbox Code Playgroud)
}
使用此模板
<ion-content padding>
<ion-item>
<p>{{imageFileName}}</p>
<button ion-button color="secondary" (click)="getImage()">Get Image</button>
</ion-item>
<ion-item>
<h4>Image Preview</h4>
<img style="display:block" [src]="imageURI" *ngIf="imageURI" alt="Ionic File" width="300" />
</ion-item>
<ion-item>
<button ion-button (click)="uploadFile()">Upload</button>
</ion-item>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
使用DestinationType.DATA_URL时,我可以显示图像,但不能创建原始文件名所需的打印文件对象,以将图像附加到我的Ionic App上的上传服务中使用的FormData.
我似乎可以找到一种方法,使用来自FILE_URI的原始文件名创建此打字稿文件对象,使用来自cordova相机本机插件的camera.getPicture创建来自DATA_URL的base64编码数据.
将文件上传到我的后端的服务只使用这种方法:
postImage(image: File): Observable<any> {
const formData = new FormData()
.append('file', image, image.name)
}
return …Run Code Online (Sandbox Code Playgroud) 如下所示,我正在使用该[src]属性.我要做的是预览从设备的相机拍摄的图像.请参阅下面的其他打字稿代码.
<img [src]="lastImage" style="width: 100%" [hidden]="lastImage === null">
<button ion-button icon-left (click)="presentActionSheet()">
<ion-icon name="camera"></ion-icon>Select Image
</button>
Run Code Online (Sandbox Code Playgroud)
这是.ts代码
lastImage: string = null;
public presentActionSheet() {
let actionSheet = this.actionSheetCtrl.create({
title: 'Select Image Source',
buttons: [
{
text: 'Load from Library',
handler: () => {
this.takePicture(this.camera.PictureSourceType.PHOTOLIBRARY);
}
},
{
text: 'Use Camera',
handler: () => {
this.takePicture(this.camera.PictureSourceType.CAMERA);
}
},
{
text: 'Cancel',
role: 'cancel'
}
]
});
actionSheet.present();
}
public takePicture(sourceType) {
// Create options for the Camera Dialog
var …Run Code Online (Sandbox Code Playgroud) 它运行在小米Mix 2手机(Android版本8.0.0)和浏览器上没有任何问题.但是当我部署到三星note 2(android版本4.4.2)时,它给出了一条应用程序错误: net :: ERR_CONNECTION_REFUSED(http:// localhost:8080)
为什么我收到此错误?
任何建议和意见将不胜感激.
凯末尔.
我尝试了很多方法来去除离子卡中的边框,但都没有成功。请帮我。这是我的 css 文件:
page-home {
ion-card, .card-ios, .card-md {
border: 0 !important;
box-shadow: 0 !important;
border: none !important;
border-style: none !important;
position: relative;
text-align: center;
// border-top: 3px solid colorofyourchosing
}
.card{
border: 0 !important;
box-shadow: 0 !important;
border: none !important;
border-style: none !important;
} }
Run Code Online (Sandbox Code Playgroud)
这是我在 home.html 中的 html 代码
<ion-card>
<img (click)="goEnvi()" src="assets/imgs/envi.svg"/>
<h6>{{"Enviroment" | translate}}</h6>
</ion-card>
Run Code Online (Sandbox Code Playgroud)
谢谢
无法解析配置“ classpath”的所有文件。
找不到com.google.android.gms:strict-version-matcher-plugin:1.1.0。
Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/strict-version-matcher-plugin/1.1.0/strict-version-matcher-plugin-1.1.0.pom https://jcenter.bintray.com/com/google/android/gms/strict-version-matcher-plugin/1.1.0/strict-version-matcher-plugin-1.1.0.jar file:/C:/Users/e1706396/.m2/repository/com/google/android/gms/strict-version-matcher-plugin/1.1.0/strict-version-matcher-plugin-1.1.0.pom file:/C:/Users/e1706396/.m2/repository/com/google/android/gms/strict-version-matcher-plugin/1.1.0/strict-version-matcher-plugin-1.1.0.jar Required by: unspecified:unspecified:unspecified > com.google.gms:google-services:4.2.0
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
在https://help.gradle.org上获得更多帮助
7s cmd中的BUILD FAILED:命令失败,退出代码为1
我正在使用插件
<plugin name="cordova-plugin-appavailability" spec="^0.4.2" />
<plugin name="cordova-plugin-camera" spec="^4.0.3" />
<plugin name="cordova-plugin-compat" spec="^1.2.0" />
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-googleplus" spec="^5.2.1">
<variable name="REVERSED_CLIENT_ID" value="xxx" />
</plugin>
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.19" />
<plugin name="cordova-plugin-mfp" spec="^8.0.2018070216" …Run Code Online (Sandbox Code Playgroud)我有Ionic 3项目,我必须升级到Ionic 5。请需要升级项目的最佳方式。
ionic3 ×10
angular ×5
android ×2
cordova ×2
ionic-native ×2
ionic2 ×2
html ×1
ionic-view ×1
ionic5 ×1
javascript ×1
paytm ×1
typescript ×1