最近,我将 Ionic 3 项目升级到了 Ionic 4,通过这次升级,其他几个软件包也得到了更新(Angular 5 --> 8 和 RxJs 5.5 --> 6.5)。代码中所需的大部分更改进展顺利,但有一个更改我无法解决。
在我的一项服务中,我有一个执行 API 获取 (GET) 的函数。fetch( http GET) 中的任何错误都在全局错误函数中处理。在我旧的 Ionic 3 / RxJs 5~ 应用程序中,这是按如下方式完成的:
public fetch(): Observable<T[]> {
let _path: string = this.path;
const url = this.getUrl(_path);
return this.http
.get(url, this.options)
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud)
该handleError函数在另一个服务中定义:
protected handleError(error: any) {
const errMsg = (error.message) ? error.message :
error.status ? `${error.status} - ${error.statusText}` : 'Server error';
this.logger.error('API endpoint: ' + this.path, errMsg);
this.showErrorToast(); // not async …Run Code Online (Sandbox Code Playgroud) 我需要显示文本,但以两行显示,但当用户单击“显示更多”时,他/她可以看到所有文本。这是我的代码
<div *ngFor="let x of announcement">
<ion-card class="group-box">
<div text-left style="font-size: 16px; font-weight: bold; color: white; top: 10%;position: relative; margin-left: 10px;">
{{x.announcementTitle}}
</div>
<div class="" text-left style="font-size: 16px; font-weight: bold; color: white; top: 25%;position: relative; margin-left: 10px;">
{{x.announcementDetails}}
</div>
<div text-right class="announcement-username">
{{x.createrName}}
</div>
</ion-card>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要在announcementDetails中添加关闭seemore/less的选项
在我的 Ionic 4 项目中,我有选项卡式界面,其中有 4 个选项卡。
我尝试ion-tab通过添加一些自定义 css 来自ion-tab-bar定义圆角,如下所示。
我使用以下代码来实现此设计。
ion-tab-bar {
border-top-left-radius: 50px;
border-top-right-radius: 50px;
}
ion-tab-button {
transition: 0.2s ease-in;
}
.tab-selected {
border-bottom: 4px white solid;
// transition: 0.2s ease-in;
font-size: 0;
ion-icon {
transform: scale(1.3);
transition: 0.2s ease-in;
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里面临的问题是,顶部有一个白色背景,重叠在我在所选选项卡页面上显示的卡片上。
我不知道为什么卡片上会出现白色背景。我希望它是透明的。我尝试通过scss选项卡组件文件更改背景颜色,但这对我不起作用。我怎样才能删除ion-tab-bar.
我使用 Ionic4 和 Angular8。
我想在智能手机上捏合/捏合屏幕。
我尝试过以下描述已添加到index.html中。
<meta name = "viewport" content = "viewport-fit = cover, width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 4.0, user-scalable = yes" />
Run Code Online (Sandbox Code Playgroud)
但事与愿违,在真机上并没有运行。
我也尝试过。
已添加以下内容。
scrollX = "true"
Run Code Online (Sandbox Code Playgroud)
然后,您现在可以在智能手机上捏合/捏合屏幕。但我不知道为什么,也不知道为什么。
另外,如果 的高度足够大以至于需要垂直滚动,我在捏合屏幕后无法水平滚动。
我不知道为什么。我想在屏幕放大后使水平滚动起作用。
如果有人知道怎么做,请告诉我。
我想在我的 Ionic 4 应用程序中使用Cordova Firebase Dynamiclinks插件:https://github.com/chemerisuk/cordova-plugin-firebase-dynamiclinks#installation。
也有一个Ionic-native-pluginnpm install @ionic-native/firebase-dynamic-links用法:和用法:
import { FirebaseDynamicLinks } from '@ionic-native/firebase-dynamic-links/ngx';
constructor(private firebaseDynamicLinks: FirebaseDynamicLinks) { }
...
this.firebaseDynamicLinks.onDynamicLink()
.subscribe((res: any) => console.log(res), (error:any) => console.log(error));
Run Code Online (Sandbox Code Playgroud)
问题是:我想使用Cordova Firebase DynamiclinkscreateDynamicLink(parameters)插件中可用的方法,但Ionic-native-plugin说
类型“FirebaseDynamicLinks”上不存在属性“createDynamicLink”。
因此,我需要直接使用Cordova Firebase Dynamiclinks,并且我尝试像这样使用它
import { cordova } from '@ionic-native/core';
...
cordova.plugins.firebase.dynamiclinks.createDynamicLink({
link: "https://google.com"
}).then(function(url) {
console.log("Dynamic link was created:", url);
});
Run Code Online (Sandbox Code Playgroud)
但出现错误
类型“(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | any[]) => …
我在角度应用程序中有一个动画
@Component({
selector: 'app-portfolio',
templateUrl: 'portfolio.page.html',
styleUrls: ['portfolio.page.scss'],
animations: [
trigger('slideInOut', [
transition(':enter', [
style({transform: 'translateY(-100%)'}),
animate('200ms ease-in', style({transform: 'translateY(0%)'}))
]),
transition(':leave', [
animate('200ms ease-in', style({transform: 'translateY(-100%)'}))
])
])
]
})
Run Code Online (Sandbox Code Playgroud)
但是,同一位置有两个元素使用它,并且它们不能同时出现在屏幕上。因此,如果我选择显示一个元素,那么另一个元素将自动隐藏。问题是我只想在另一个元素没有动画时动画出来。有没有办法只在满足条件时显示动画?像这样的东西吗?
<ion-item color="primary" (element2open === false)=[@slideInOut] *ngIf="openElement1" lines="none">
</ion-item>
<ion-item color="primary" (element1open === false)=[@slideInOut] *ngIf="openElement2" lines="none">
</ion-item>
Run Code Online (Sandbox Code Playgroud) 我正在用 Angular 和 ionic 编写一个信使。我想scrollToBottom在滚动到最大底部时触发该方法。因为如果有人滚动顶部查看旧消息,而合作伙伴正在发送任何消息,那么他不会每次都被踢到底部。
这是文档: https: //ionicframework.com/docs/api/content但我找不到任何可以帮助我解决这个问题的文档。
我这样设置地图:
this.map = new Map({
target: 'map',
layers: [new TileLayer({source: new OSM()})
],
view: new View({
center: [0, 0],
zoom: 16,
})
});
Run Code Online (Sandbox Code Playgroud)
打开页面后我得到这个:
所以我打开控制台来缩小页面并加载地图:
您知道如何修复它吗?
我\xe2\x80\x99m 试图找到一种方法来使用电容器打开设置/首选项应用程序,但我\xe2\x80\x99m 不成功。
\n\nApp.canOpenUrl({ url: \'com.apple.Preferences\' })失败并显示错误消息-canOpenURL: failed for URL: "com.apple.Preferences" - error: "Invalid input URL"
我\xe2\x80\x99m 不确定我\xe2\x80\x99m 是否做错了,或者\xe2\x80\x99s 是否甚至可以使用电容器打开本机应用程序\xe2\x80\xa6?
\n\n本文展示了如何打开 facebook 应用程序,但没有介绍本机应用程序
\n我想发布多部分表单数据,为此,我们可以这样做:
\n\nlet formData = new FormData()\nformData.append(\'myfile\', \'your blob\')\n\nthis.http.post(url, formData)\nRun Code Online (Sandbox Code Playgroud)\n\n但我不知道如何将相机图像转换为斑点。我正在使用本机相机插件,这里是我的代码:
\n\n cameraOptions: CameraOptions = {\n quality: 20,\n destinationType: this.camera.DestinationType.DATA_URL,\n encodingType: this.camera.EncodingType.JPEG,\n mediaType: this.camera.MediaType.PICTURE,\n sourceType: this.camera.PictureSourceType.PHOTOLIBRARY\n }\n\nconstructor(public camera: Camera){}\n\ntakePhoto() {\n return new Promise(resolve => {\n this.camera.getPicture(this.cameraOptions).then((imageData) => {\n resolve(imageData);\n }, (err) => {\n resolve(err);\n });\n });\n }\nRun Code Online (Sandbox Code Playgroud)\n\n我为 blob 尝试了以下代码:
\n\ndataURLtoBlob(dataURL) {\n debugger;\n // convert base64/URLEncoded data component to raw binary data held in a string\n let byteString: string;\n if (dataURL.split(\',\')[0].indexOf(\'base64\') >= 0) {\n byteString = atob(dataURL.split(\',\')[1]);\n …Run Code Online (Sandbox Code Playgroud) ionic-framework ×10
angular ×7
javascript ×2
typescript ×2
animation ×1
capacitor ×1
cordova ×1
css ×1
firebase ×1
html ×1
ion-content ×1
ionic4 ×1
ionic5 ×1
openlayers ×1
pinch ×1
rxjs ×1