我尝试在.ts文件中设置一个间隔,但我不明白如何在间隔中的同一文件中使用一个函数.
解释 :
我的间隔设置:
this.task = setInterval(function () {
this.refreshData();
}, 300);
Run Code Online (Sandbox Code Playgroud)
我的功能在同一个ts文件中:
refreshData() : void{
console.log('update...');
}
Run Code Online (Sandbox Code Playgroud)
当我在我的设备上运行时,我有这个错误:
04-19 10:38:57.535 21374-21374/com.ionicframework.app722890 I/chromium: [INFO:CONSOLE(79432)] "TypeError: this.refreshData is not a function
at file:///android_asset/www/build/main.js:10987:18
at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:10284)
at Object.onInvokeTask (file:///android_asset/www/build/main.js:39626:37)
at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:10220)
at e.runTask (file:///android_asset/www/build/polyfills.js:3:7637)
at invoke (file:///android_asset/www/build/polyfills.js:3:11397)
at e.args.(anonymous function) (file:///android_asset/www/build/polyfills.js:2:30193)", source: file:///android_asset/www/build/main.js (79432)
Run Code Online (Sandbox Code Playgroud)
我尝试这种方式,但我不工作:
this.task = setInterval(this.refreshData(), 300);
Run Code Online (Sandbox Code Playgroud)
这只调用我的函数一次.
有人有想法吗?
我正在使用离子3同时在同一页面上放置3个滑动滑块我无法分别控制它们的行为我对角度js以及ts和离子有点新
这是代码
<ion-slides style="height: 30%;" pager>
<ion-slide style="background-color: green" *ngFor="let post of posts">
<h1>{{post.title}}</h1>
<img [src]="post.image" />
</ion-slide>
</ion-slides>
<ion-slides style="height: 30%;" pager>
<ion-slide style="background-color: green" *ngFor="let post of posts">
<h1>{{post.title}}</h1>
<img [src]="post.image" />
</ion-slide>
</ion-slides>
Run Code Online (Sandbox Code Playgroud)
ts是
@ViewChild(Slides) slides: Slides;
goToSlide() {
this.slides.slideTo(2, 500);
}
ngAfterViewInit() {
//this.slides.freeMode = true;
this.slides .slidesPerView=3,
this.slides.spaceBetween=5;
//this.slides.loop=true;
}
Run Code Online (Sandbox Code Playgroud) 我目前将我的Cordova + Angular2项目之一移植到Ionic 3.8 + Angular 4.1.3.我的项目使用了一些第三部分JS和CSS库,如Font awesome,Slick carousel等.在之前的版本中,我使用webpack打包我的应用程序,下面是我如何管理第三方css和JS.
.angular-cli.json
"styles": [
"styles.css",
"css/animate.css",
"css/font-awesome.css",
"css/slick.css",
"css/slick-theme.css"
],
"scripts": [
"scripts/jquery-3.2.1.min.js",
"scripts/slick.min.js",
"scripts/slideout.min.js"
],
Run Code Online (Sandbox Code Playgroud)
我如何用Ionic实现同样的目标?我已经完成了在线提供的解决方案,但是大多数人都建议将css与全局scss文件相结合,甚至调整离子.对于角度cli,是否有一个简单的解决方案?
我在离子3应用程序的其他提供商中包括提供商.但它给了我错误'找不到供应商'.我做了一些研究,发现它是由于循环依赖.如何克服离子3应用程序中的循环依赖?
关于此主题还有其他几个问题/答案,但他们没有将Firebase与Ionic一起使用.我刚刚切换到新的Ionic View,现在,我的应用程序在旧的Ionic View中工作,而新的Ionic View给出了这个众所周知的错误:
403错误 - 这是一个错误.错误:disallowed_useragent不允许其用户代理向Google发出OAuth授权请求,因为它被归类为嵌入式用户代理(也称为Web视图).等等等等等等
在我的代码中,我注入Firebase AuthProvider并使用angularfire2进行连接,它看起来像
private getProvider(from: string): AuthProvider {
switch (from) {
case 'twitter': return new firebase.auth.TwitterAuthProvider();
case 'facebook': return new firebase.auth.FacebookAuthProvider();
case 'github': return new firebase.auth.GithubAuthProvider();
case 'google': return new firebase.auth.GoogleAuthProvider();
}
}
signIn(from: string) {
this.afAuth.auth.signInWithPopup(this.getProvider(from))
. . .
Run Code Online (Sandbox Code Playgroud)
再次,这在浏览器或旧的Ionic中很有用,但不适用于新的Ionic View.我确实有一个相当大的库与一般OAuth连接,但我认为使用Firebase的一个重要原因是我们不再需要使用这些库并自己管理用户.
有没有办法通过Ionic在iOS/Android应用上进行Firebase身份验证?
firebase firebase-authentication angularfire2 ionic3 angular
林用这个https://devdactic.com/dynamic-theming-ionic/我的大学项目的应用程序,主题背景变化的工作,但一些IHAVE问题,(theme.dark不行)离子情态动词 为无主题选项,其他页面正在工作,如何解决这个问题谢谢
我的代码
提供者 - settings.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/Rx';
@Injectable()
export class SettingsProvider {
private theme: BehaviorSubject<String>;
constructor() {
this.theme = new BehaviorSubject('dark-light');
}
setActiveTheme(val) {
this.theme.next(val);
}
getActiveTheme() {
return this.theme.asObservable();
}
}
Run Code Online (Sandbox Code Playgroud)
页/ setting.html
<ion-content padding>
<p text-center>Theme settings</p>
<button ion-button full icon-left (click)="toggleAppTheme()" (click)="presentLoading()" style="background: lightgrey;color: #263447;">
<ion-icon name="sunny"></ion-icon>Light
</button>
<button ion-button full icon-left (click)="toggleAppThemes()" (click)="presentLoading()" style="background: #263447;color: white;">
<ion-icon name="bulb"></ion-icon>Dark
</button>
</ion-content> …Run Code Online (Sandbox Code Playgroud) 我对在不同情况下没有出现的侧面菜单有点超级烦恼和困惑.
我的应用流程和要求是:最初有一个包含3个选项卡且没有侧边菜单的登录页面.在第一个选项卡上有产品,您可以将它们添加到购物车.一旦你将它们添加到购物车,你可以点击购物车结帐.此时,如果用户尚未登录,则会显示模型弹出窗口,并显示登录facebook选项.在成功登录时,订单摘要页面会显示添加到购物车的商品.用户现在已登录,因此应显示侧边菜单.
然而,正在发生的是菜单图标显示但点击没有任何反应.控制台等没有错误
我已经验证,如果我没有检查用户登录状态,那么在登录页面上菜单显示就好了.
相关代码: app.html
<ion-menu [content]="content" type="overlay" style="opacity:0.95">
<ion-header>
<ion-toolbar>
<ion-title>
Menu
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content style="background-color: #F5F5F6">
<ion-grid no-padding>
<ion-row style="padding-top:20px">
<ion-col text-center>
<button ion-button round (click)="doLogout()">Sign Out</button>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content></ion-nav>
Run Code Online (Sandbox Code Playgroud)
app.component.ts
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage:any = TabsPage;
}
Run Code Online (Sandbox Code Playgroud)
home.html(第一个标签)
ion-header>
<ion-navbar>
<button *ngIf="core.user.loggedIn == true" ion-button menuToggle icon-only style="display: block !important;">
<ion-icon name='menu'></ion-icon>
</button>
<ion-title>Cakes</ion-title>
<ion-buttons end>
<button *ngIf="getCartCount() > 0" ion-button (click)="openCart()"><ion-icon …Run Code Online (Sandbox Code Playgroud) 我有一个使用网络套接字和使用ngrx/store的redux的Ionic 3应用程序.起初我的所有代码都在开发模式下正常工作.在浏览器和真实设备中.
但是当我尝试在生产模式下构建它时.仍然会调度该操作,但reducers没有收到已分派的操作,导致应用程序的状态未更新.
这是我的减速机下面的代码.
import { Action } from '@ngrx/store';
const UPDATE_AVATAR = '[Websokcet] New ORDER';
type Type = UpdateAvatar
export class UpdateAvatar implements Action {
readonly type = UPDATE_AVATAR;
constructor(public payload: any) { }
}
export function UpdateAvatarReducer(state: any, action: Type) {
console.log('ACTION RECEIVED:', state, action)
switch (action.type) {
case UPDATE_AVATAR:
return action.payload;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的rootReducers中
import { UpdateAvatar, UpdateAvatarReducer } from './reducers/uploadAvatar';
export function rootReducer () {
return …Run Code Online (Sandbox Code Playgroud) 我不确定为什么将GA导入单元测试失败。我怎样才能解决这个问题?
也许JEST错误应该使我指向正确的方向,但不幸的是,它没有:
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Run Code Online (Sandbox Code Playgroud)
....
/Users/me/app/node_modules/@ionic-native/google-analytics/index.js:20
import { Injectable } from '@angular/core';
^^^^^^
SyntaxError: Unexpected token import
2 | import { Http } from '@angular/http';
3 | import { Events } from 'ionic-angular';
> 4 | import { GoogleAnalytics …Run Code Online (Sandbox Code Playgroud) 我认为Ionic在iOS中有一个巨大的错误。我收到以下错误消息:
2019-11-06 12:09:31.560205+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.560562+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.660322+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.660699+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.765716+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.767176+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.862421+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:31.863232+0100 MyApp[6687:1400464] [Process] kill() returned unexpected error 1
2019-11-06 12:09:33.680251+0100 MyApp[6687:1400464] [Process] kill() returned unexpected …Run Code Online (Sandbox Code Playgroud) ionic3 ×10
angular ×7
ionic2 ×2
typescript ×2
angularfire2 ×1
angularjs ×1
cordova ×1
css ×1
firebase ×1
ion-navbar ×1
ionic4 ×1
ios ×1
javascript ×1
jestjs ×1
ngrx-store ×1
redux ×1
unit-testing ×1
wkwebview ×1