我使用ionic start test sidemenu --type=angular.
然后,不做任何更改,我运行ionic cordova run browser并自动打开浏览器,一切正常并且很好。
问题是,如果我尝试/platforms/browser/www/index.html直接在浏览器中打开文件,则会出现黑页和failed to load resources文件错误:runtime.js, polyfills.js, styles.js, cordova.js, vendor.js, vendor.js.
如果我运行相同的行为ionic cordova run browser --prod。
使用 ionic 3 我没有错误。
加载资源失败:
我的离子信息是:
Ionic:
ionic (Ionic CLI) : 4.2.1 (/usr/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.13
@angular-devkit/build-angular : 0.8.6
@angular-devkit/schematics : 0.8.6
@angular/cli : 6.2.6
@ionic/angular-toolkit : 1.0.0
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : browser 5.0.4
Cordova Plugins : cordova-plugin-ionic-keyboard …Run Code Online (Sandbox Code Playgroud) 我正在尝试使 ios 上的段看起来与它们在 android 上的外观相同。参考https://beta.ionicframework.com/docs/api/segment
我尝试使用 css 属性,例如
segment-button-checked {
--background-checked: transparent !important;
--color-checked: white !important;
border-bottom: 1 px solid white
}
ion-segment-button {
--color: #8CA2A5;
--border-color: transparent !important
}
Run Code Online (Sandbox Code Playgroud)
选定的按钮属性不会以这种方式工作。并且整体视觉上看起来不像在 android 上看起来那么好看
我一直在使用下面的代码返回上一页:
<ion-toolbar color="primary">
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
</ion-toolbar>
Run Code Online (Sandbox Code Playgroud)
我有一个要求,当单击背面时,我需要重新渲染以前的组件。
我尝试过生命周期挂钩,例如ngOnInit(),ngAfterViewInit()等,但是当调用后退按钮时,没有一个被调用。
请让我知道一种可能的方式来处理此要求。
我正在使用 Ionic 4 构建一个用于发送紧急短信的应用程序,因此我需要以编程方式发送它,而无需进入本机短信应用程序。
我使用以下代码:
async sendSMS(){
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.SEND_SMS).then(
result => console.log('Has permission?'+result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.SEND_SMS )
);
var options = {
replaceLineBreaks: true, // true to replace \n by a new line, false by default
android: {
//intent: 'INTENT' // send SMS with the native android SMS messaging
intent: '' // send SMS without opening any other app
}
};
try{
await this.sms.send(this.phoneNumber.toString(),this.textMessage,options);
console.log("sent");
this.mostrarToast("mensage sent");
}
catch(e){
console.log(JSON.stringify(e));
console.log(e);
this.mostrarToast(e);
}
Run Code Online (Sandbox Code Playgroud)
当我打开我的 logcat 我得到这个:
2019-03-19 21:17:12.255 11786-11786/io.ionic.starter I/chromium: [INFO:CONSOLE(168)] …Run Code Online (Sandbox Code Playgroud) 我正在使用 ngx-translator 包,但它无法在我的应用程序中设置默认语言。
这是我的app.module.ts:
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClientModule, HttpClient } from '@angular/common/http';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
AppRoutingModule, HttpClientModule],
providers: [
StatusBar,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
这是我的app.component.ts:
import { TranslateService …Run Code Online (Sandbox Code Playgroud) 我想制作一个编辑表单,我需要在 ion-datetime 中设置一个默认日期。
.html
<ion-datetime #fecha displayFormat="DD/MM/YYYY" [(ngModel)]="myVar" pickerFormat="DD MM YYYY" doneText="Ok" cancelText="Cancelar"></ion-datetime>
Run Code Online (Sandbox Code Playgroud)
.ts
public myVar = "15-06-1999";
Run Code Online (Sandbox Code Playgroud) 我试图寻找任何讨论,但没有找到答案。在指定的离子文档中
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log('Error getting location', error);
});
Run Code Online (Sandbox Code Playgroud)
我的代码是这样的
this.geolocation.getCurrentPosition().then(pos => {
let latLng = new google.maps.latLng(pos.coords.latitude, pos.coords.longitude);
this.map.setCenter(latLng);
this.map.setZoom(15);
}).catch(err => {
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
当我悬停时。我收到消息
(method) Geolocation.getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void
Expected 1-3 arguments, but got 0.ts(2554)
lib.dom.d.ts(5389, 24): An argument for 'successCallback' was not provided.
Run Code Online (Sandbox Code Playgroud)
我模仿了YouTube上的教程https://www.youtube.com/watch?v=Ru57AkoWMJ4&t=199s
我在他的第 43 行出现错误
我刚刚开始使用 ionic 4,现在我正在搜索一个基本问题,如何在 Ionic 4 中关闭菜单。 ionic 4 到目前为止还没有正确记录。请任何人回答我。提前致谢。
Firebase API 从后端推送有效负载:
{
"registration_ids": [
"IKSiok9Zpip5cDcebQ67wc7TnpDuhMAFJm1xdGGI44s48JbXEu5iYa"
],
"notification": {
"body": "Push Test Facility Category",
"title": null,
"icon": "myicon",
"sound": "mySound",
"vibrate": 1,
"Badge": 1,
"click_action": "FCM_PLUGIN_ACTIVITY"
},
"data": {
"message": "Push Test Facility Category",
"title": null,
"b": "22",
"id": "2",
"category_name": "Restaurants",
"h": "1",
"p": 1,
"type": "2"
}
}
Run Code Online (Sandbox Code Playgroud)
fcm.service.ts
fcmListeners() {
this.firebase.onNotificationOpen().subscribe(async (data: any) => {
if (data.tap) {// when user tapped the background notification
} else { // Received in foreground
}
});
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我为什么当我使用上述有效负载并且应用程序在后台时应用程序没有打开吗?这是 Android …
我正在尝试创建具有透明背景的模态,但是它不起作用
ion-content {
--background-color: rgba(255, 255, 255, 0.7);
}
.closeBtn {
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
}Run Code Online (Sandbox Code Playgroud)
<ion-content padding>
<h3 class="ion-text-center">
<strong>Test.</strong>
</h3>
<ion-button class="closeBtn" color='light' fill='clear'>Close</ion-button>
</ion-content>Run Code Online (Sandbox Code Playgroud)
我希望看到一些透明性。