我试图将我的Ionic应用程序作为ios本机应用程序运行,并且遇到一个奇怪的URL连接错误,该错误阻止数据填充到我的应用程序视图中。当我以iphone的形式在网络浏览器中运行该应用程序时,它可以正常运行并填充,但是在本机ios上运行时,它并没有使用API数据按预期填充页面。我已经检查了控制台,实际上已经调用了API,但是xcode控制台正在打印出填充页面数据的2个API调用的以下内容:
2018-02-19 11:30:21.199933-0500 MyApp[1429:350591] NSURLConnection finished with error - code -1100
2018-02-19 11:30:21.202556-0500 MyApp[1429:350591] NSURLConnection finished with error - code -1100
Run Code Online (Sandbox Code Playgroud)
我已经看到并看到代码-1100通常是一个找不到文件的问题类型,但是我不确定这将如何发生,因为它只是通过API调用返回数据,然后将其存储在离子卡格式。
我有一个Ionic2和Angular2 的项目。
我在代码中使用RamdaJS,可以完美地与以下命令配合使用:
ionic serve ionic cordova build android ionic cordova run android但是,当我尝试执行以下命令:时ionic cordova build android --prod --release,出现有关Ramda和Type的错误。
看到我的一部分package.json:
"dependencies": {
"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/flex-layout": "^2.0.0-rc.1",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/material": "2.0.0-beta.2",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@angular/router": "3.4.8",
"@ionic-native/camera": "3.7.0",
"@ionic-native/core": "3.7.0",
"@ionic-native/network": "3.7.0",
"@ionic-native/splash-screen": "3.7.0",
"@ionic-native/status-bar": "3.7.0",
"@ionic/storage": "2.0.0",
"cordova-plugin-device": "^2.0.1",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"hammerjs": "2.0.8",
"ionic-angular": "2.3.0", …Run Code Online (Sandbox Code Playgroud) 当我进入我的内置签名并发布的Ionic应用程序时,我的日志上出现此错误.知道怎么解决这个问题吗?
Ionic version - 3.19.1
Cordova version - 7.1.0
Node version - 8.9.3
Run Code Online (Sandbox Code Playgroud)
日志:
02-21 11:13:00.335 2111-11520/? I/WindowManager: Switching to real app window: Window{d547428 u0 io.ionic.app/io.ionic.app.MainActivity}
02-21 11:13:00.437 2111-2156/? I/ActivityManager: Displayed io.ionic.app/.MainActivity: +1s64ms
02-21 11:13:08.903 2634-2634/? I/LatinIme: onActivate() : EditorInfo = Package = io.ionic.app : Type = Text : Learning = Disable : Suggestion = Hide : AutoCorrection = Disable : Microphone = Show : Incognito = Disable
02-21 11:13:08.986 2634-2634/? W/Conv2QueryExtension: Conv2Query not enabled due to current app [io.ionic.app] …Run Code Online (Sandbox Code Playgroud) 我对角度/离子应用程序开发很新.我在某处读了以下内容
接口仅在编译时.这样只允许您检查收到的预期数据是否遵循特定结构.
我正在创建一个离子应用程序,API服务会将一些数据返回给用户.假设它是一个登录函数,API服务返回该数据.
我在Ionic中创建了一个提供程序,使用HTTPClient从API调用API.
//Provider
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
interface LoginResponse {
success: boolean;
message: string;
token: string;
userId: number;
}
@Injectable()
export class LoginServicesProvider {
constructor(public http: HttpClient) {
}
login(reqData): Observable<LoginResponse[]> {
return this.http.post<LoginResponse[]>('localhost:3000/api/login', reqData);
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我创建了一个名为LoginResponse的接口
Login组件的代码如下:
//Component
import { LoginServicesProvider } from './../../providers/login-services/login-services';
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'page-login-page',
templateUrl: 'login-page.html',
}) …Run Code Online (Sandbox Code Playgroud) 我知道此链接:https : //cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#where-to-store-files
但我想将文件保存在下载目录中。是否可以使用Ionic将文件保存在任何路径中?如果是这样,请分享示例。
这是代码:
downloadImage(image) {
this.platform.ready().then(() => {
const fileTransfer: TransferObject = this.transfer.create();
const imageLocation = `${cordova.file.applicationDirectory}www/assets/img/${image}`;
fileTransfer.download(imageLocation, cordova.file.externalDataDirectory + image).then((entry) => {
const alertSuccess = this.alertCtrl.create({
title: `Download Succeeded!`,
subTitle: `${image} was successfully downloaded to: ${entry.toURL()}`,
buttons: ['Ok']
});
alertSuccess.present();
}, (error) => {
const alertFailure = this.alertCtrl.create({
title: `Download Failed!`,
subTitle: `${image} was not successfully downloaded. Error code: ${error.code}`,
buttons: ['Ok']
});
alertFailure.present();
});
});
}
Run Code Online (Sandbox Code Playgroud)
基本上,我想将文件保存在用户可见的位置。
我正在尝试为Android构建一个离子应用程序,但是当我运行时
ionic cordova run android
Run Code Online (Sandbox Code Playgroud)
我明白了
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
Run Code Online (Sandbox Code Playgroud)
试着运行./gradlew clean让我
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type FileHasher using BuildSessionScopeServices.createFileSnapshotter().
Run Code Online (Sandbox Code Playgroud) 我想知道如何确保ion-list显示正确的内容.
该ion-list如下所示:
<ion-list [virtualScroll]="list" [approxItemHeight]="'132px'">
<ion-item *virtualItem="let item">
<span item-start>{{item.foo}}</span>
</ion-item>
</ion-list>
Run Code Online (Sandbox Code Playgroud)
单元测试:
it('should display the correct content', () => {
comp.list = [ { foo: 'bar' } ];
fixture.detectChanges();
de = fixture.debugElement.query(By.css('ion-content'));
el = de.nativeElement;
console.log(el);
});
Run Code Online (Sandbox Code Playgroud)
这输出:
<ion-list class="list list-md virtual-loading" ng-reflect-virtual-scroll="[object Object],[object Object" ng-reflect-approx-item-height="132px">
<!---->
</ion-list>
Run Code Online (Sandbox Code Playgroud)
如何触发因果报应来呈现ion-item的ion-list?
我正在使用一个 ion-select,我正在启用该multiple属性来选择几个选项.如果已经检查了3个选项,我找不到实时禁用其余选项的方法.我目前正在使用该ionSelect事件,但它仅在选中选项时有效.我怎样才能解决我的问题?我怎样才能解决我的问题?我想知道我是如何知道我已经标记了多少选项并实时获得它们的价值.
这是我的代码:https: //stackblitz.com/edit/ionic-8wewvd?file = pages/home/home.ts
页/家
<ion-label>Select a person</ion-label>
<ion-select [(ngModel)]="person" multiple="true">
<ion-option *ngFor="let item of options; let i = index"
[value]="item.id" (ionSelect)="fn_checkOptions()" >
{{item.name}}
</ion-option>
</ion-select>
export class HomePage {
public options:object=[];
constructor(public navCtrl: NavController) {
this.options=
[
{"name":"pedro","id":1},
{"name":"juan","id":2},
{"name":"maria","id":3},
{"name":"velez","id":4},
{"name":"yaya","id":4}
]
}
fn_checkOptions(){
alert("hey")
}
}
Run Code Online (Sandbox Code Playgroud) 我第一次使用离子4的beta.我尝试在登录页面上禁用菜单,但是我遇到了一些麻烦.
我用ionic-cli和sidemenu模板创建了应用程序,然后生成了一个登录页面.
我<ion-split-pane>从app.component.html中删除了它
我修改了app-routing.module.ts以重定向到我的登录屏幕.在我的登录文件中,我尝试放置一个ngOnInit事件来禁用此特定页面上的菜单
import { Component, OnInit, AfterContentInit, AfterViewInit,OnDestroy } from '@angular/core';
import { MenuController } from '@ionic/angular';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit, AfterContentInit, AfterViewInit,OnDestroy {
constructor(public menuCtrl: MenuController) {}
ngOnInit() {
this.menuCtrl.enable(false);
this.menuCtrl.swipeEnable(false);
}
ngAfterContentInit() {
this.menuCtrl.enable(false);
this.menuCtrl.swipeEnable(false);
}
ngAfterViewInit() {
this.menuCtrl.enable(false);
this.menuCtrl.swipeEnable(false);
}
ngOnDestroy() {
this.menuCtrl.enable(true);
this.menuCtrl.swipeEnable(true);
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试在离子菜单中设置了id
<ion-menu swipeEnabled="true" #menu>
Run Code Online (Sandbox Code Playgroud)
并改变我的代码
this.menuCtrl.enable(false, 'menu');
Run Code Online (Sandbox Code Playgroud)
它不起作用,有人可以帮助我.
谢谢
带有ionic 4的iOS设备上的Livereload(离子Cordova运行ios -l)似乎不起作用。它停留在初始屏幕的初始加载中。我已经尝试了离子项目开始空白后马上进行新项目,但仍然无法正常工作。
浏览器上的livereload(离子服务)和模拟器(离子cordova模拟ios -l)工作正常。
离子信息:
Ionic:
ionic (Ionic CLI) : 4.0.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11
Cordova:
cordova (Cordova CLI) : 7.1.0
Cordova Platforms : ios 4.5.5
System:
ios-deploy : 2.0.0
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Device info:
iphone X, iOS 11.4 (15F79)
Run Code Online (Sandbox Code Playgroud)
有没有人知道如何解决这个问题?
谢谢
ionic-framework ×10
cordova ×4
ionic3 ×3
android ×2
angular ×2
ionic2 ×2
ionic4 ×2
ios ×2
typescript ×2
angular6 ×1
gradle ×1
jasmine ×1
karma-runner ×1
livereload ×1
ramda.js ×1