我扼杀了能够捕捉到这个错误。在桌面上,此代码引发了以下问题 NotSupportedError:
我通常在 chrome 上调试。
这是代码:
import {Component} from "@angular/core";
import {ScreenOrientation} from "@ionic-native/screen-orientation";
@IonicPage()
@Component({
selector: 'page-loading',
templateUrl: 'page-loading.html',
})
export class PageLoading {
constructor(private screenOrientation:ScreenOrientation) {}
ionViewDidLoad() {
console.log('ionViewDidLoad PageLoading');
try{
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT).then(()=>{
console.log('lock');
});
}catch(e){
console.warn('No cordova.js')
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在 app.module.ts 中使用 TranslateHttpLoader 从服务器加载翻译文件,如下所示:
export function createTranslateLoader(http: Http) {
return new TranslateHttpLoader(http, AppConfig.API_URL+'/static/i18n/', '.json');
}
@NgModule({
...
imports: [
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http]
}
}),
],
...
})
Run Code Online (Sandbox Code Playgroud)
一切正常,但我想知道是否有办法在加载程序因任何原因(服务器问题、网络连接等)无法检索语言文件时捕获事件,并可能加载带有一些默认翻译字符串的本地 json 文件?
如果第一次加载的应用程序无法获取语言文件,我想捕获此事件,并回退到最小的本地 json 文件以仅显示翻译的维护页面/错误页面或其他内容。
我正在使用以下插件从 android 应用程序获取背景地理定位, https://github.com/mauron85/cordova-plugin-background-geolocation
是否有任何可能的方法可以在八小时后以某种方式停止插件或将其安排在特定的时间段内。以下是我的离子信息,
cli包:
@ionic/cli-plugin-proxy : 1.4.13
@ionic/cli-utils : 1.13.1
ionic (Ionic CLI) : 3.13.1
Run Code Online (Sandbox Code Playgroud)
全局包:
cordova (Cordova CLI) : 7.1.0
Run Code Online (Sandbox Code Playgroud)
本地包:
@ionic/app-scripts : 3.0.0
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.7.1
Run Code Online (Sandbox Code Playgroud)
系统:
Android SDK Tools : 26.0.2
Node : v6.10.2
npm : 5.5.1
Run Code Online (Sandbox Code Playgroud) 我想要这样的东西:
firebase.auth().currentUser.canWrite();
Run Code Online (Sandbox Code Playgroud)
这应该返回true或false基于我在 Firebase 控制台中制定的安全规则。
admin firebase-security firebase-authentication firebase-realtime-database ionic3
按照 Firebase 教程实现 Firebase 托管。在控制台中托管应用程序。但问题是当我更改了 html 模板并通过运行在 Firebase 控制台中重新部署时
ionic build --browser
Run Code Online (Sandbox Code Playgroud)
和
firebase deploy
Run Code Online (Sandbox Code Playgroud)
它正在部署,但未在移动浏览器中更新。
例如,我创建了一个离子和角度演示项目。使用 InAppBrowser 可以连接 Firebase url
this.iab.create('https://xxx-xxxx.firebaseapp.com','_blank',"location=no,clearsessioncache=yes,clearcache=yes");
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在应用程序设置中清除应用程序缓存时。然后我得到输出
上面带有更新文本的图像。上传到 firebase 后的预期结果。
下面的片段试图限制缓存。
1. clearsessioncache=yes,clearcache=yes given in InAppBrowser
Run Code Online (Sandbox Code Playgroud)
2.在Firebase.json
"headers": [ {
"source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}, {
"source" : "**/*.@(jpg|jpeg|gif|png)",
"headers" : [ {
"key" : "Cache-Control",
"value" : "max-age=7200"
} ]
}, {
"source" : "404.html",
"headers" : [ { …Run Code Online (Sandbox Code Playgroud) 如何在 Ionic 3 PWA 中定义可选参数?
我当前的@IonicPage装饰器看起来像:
@IonicPage({
segment: "landing/:id"
})
Run Code Online (Sandbox Code Playgroud)
但id参数必须是可选的。如果我没有通过id,我会收到此错误:
未捕获(承诺):要插入的无效视图
怎么做?
提前致谢!
我遵循了官方文档,我的代码如下:
let alert = this.alertCtrl.create({
title: 'Alert',
subTitle: 'Subtitle',
message: 'This is an alert message.',
buttons: ['OK'],
cssClass: 'profalert'
});
alert.present();
Run Code Online (Sandbox Code Playgroud)
和我的 CSS:
.profalert{
color:#e7333c;
background-color: red;
}
Run Code Online (Sandbox Code Playgroud)
但这并没有改变警报框的颜色。我也试过alert .setCssClass('profalert');
我已经检查过这个
我想提供带有ion-select 的选择选项。我在第一个位置手动添加了全选选项,当我全选视图未更新时。如何更新视图?
<ion-select multiple="true">
<ion-option (ionSelect)="allClicked()">select all</ion-option>
<ion-option *ngFor="let item of students ; let i = index" [selected]="item.checked" [value]="item">{{item.studentName}}</ion-option>
</ion-select>
Run Code Online (Sandbox Code Playgroud)
.ts
allClicked(){
if(this.isAll){
console.log(this.isAll)
this.isAll = false;
for (let temp of this.students) {
temp.checked = false;
}
}else{
this.isAll = true;
for (let temp of this.students) {
temp.checked = true;
}
}
console.log("all select event ");
}
Run Code Online (Sandbox Code Playgroud) process.env.IONIC_ENVdev总是回来。
这是我使用过的脚本。
ionic serve --prod
但是process.env.IONIC_ENV正在返回dev而不是prod.
有什么想法吗?
谢谢。
我在离子应用中遇到了这个问题。这个问题存在于iOS设备唯一
问题:每当我点击ion-input或简单地点击input文本框或文本区域时,键盘都会打开,这很好,但文本光标不会出现在输入中。我必须再次点击以显示文本光标。
有人知道如何解决这个问题吗??
我的离子和角度细节
Ionic Framework: 3.8.0
Ionic App Scripts: 3.0.1
Angular Core: 4.4.4
Angular Compiler CLI: 4.4.4
Node: 6.10.3
Run Code Online (Sandbox Code Playgroud) ionic3 ×10
angular ×6
typescript ×3
ionic2 ×2
admin ×1
android ×1
caching ×1
firebase ×1
geolocation ×1