我正在使用 Angular 4/Ionic 3 构建一个应用程序,加载用户从服务器上传的图像。我目前正在使用下面的代码,但它不起作用:
<img src="{{user.image}} || assets/images/profileimage.png" />
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么。我想在主图像从服务器加载之前它会显示占位符图像。相反,在主图像加载之前它仍然是空白的。我应该使用 Angular 特有的东西吗?
我的移动应用程序会连续将多个文件上传到服务器,这些文件通常来自连接强度存在问题的偏远地区。为此,我想尝试几次发送文件。我还想在失败时继续尝试下一个,导出结束时显示所有错误消息(即“已上传 10 个文件,3 个失败...”)
但是,我无法弄清楚带有承诺的递归重试模式。这是我到目前为止所拥有的:
sendFile(params, retries = 3){
console.log("SENDING FILE: ", retries, "attempts remaining", params)
return new Promise((resolve, reject)=>{
if(retries > 0){
this._sendFile(params)
.then(()=>{
// Upload Success
console.log("Upload Success!")
resolve()
})
.catch((err)=>{
console.log("Upload Fail", err)
// Retry
this.sendFile(params, --retries)
})
}else{
console.log("Failed 3 times!!!")
//Record error
this.exportStatus.errors.push({
message:"A file failed to upload after 3 attempts.",
params: params
})
//Resolve and move on to next export
resolve()
}
})
}
_sendFile(params){
// Mobile - File Transfer
let options = { …Run Code Online (Sandbox Code Playgroud) 我必须在 Ionic 3 应用程序中的 API 响应后保存 cookie,但我无法执行此操作,我需要您的帮助。
我在请求之前创建一个拦截器并在所有结果“withCredentials = true”上进行设置,但这不起作用,您是否有其他资源可以执行此操作?按照我下面的代码操作
private getRequestOptionArgs(options?: RequestOptionsArgs) : RequestOptionsArgs {
if (options == null) {
options = new RequestOptions({ withCredentials: true });
}
if (options.headers == null) {
options.headers = new Headers();
}
options.headers.append('Content-Type', 'application/json');
options.headers.append('Access-Control-Allow-Credentials', 'true');
options.headers.append('Access-Control-Allow-Origin', '*');
options.withCredentials = true
return options;
}
Run Code Online (Sandbox Code Playgroud) 我需要创建UI,如下所示.我需要订购name alphabetically和需要分组A,B等等.
我已完成第一部分(即按字母顺序使用命名lodash),如下所示.
contacts.html
<ion-list>
<ion-item *ngFor="let c of contacts | async">
<name-and-rating item-start [data]="c"></name-and-rating>
<ion-input type="text" text-right disabled="true" [value]="c.company">
</ion-input>
</ion-item>
</ion-list>
Run Code Online (Sandbox Code Playgroud)
name-and-rating.html(组件)
<div>
<div>
{{data.name}}
</div>
<div>
<rating [ngModel]="data?.rating" (ngModelChange)="data.rating=$event" readOnly="true" max="5" emptyStarIconName="star-outline"
halfStarIconName="star-half" starIconName="star" nullable="false" name="rating" item-end>
</rating>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
附加contact.ts
addContact() {
this.storage.get('contacts').then((val: Contact[]) => {
this.contacts = val;
if (this.contacts == null) this.contacts = [];
this.contacts.push(this.data);
const sortedContacts = orderBy(this.contacts, [c => c.name.toLowerCase()], ['asc']);
this.storage.set('contacts', sortedContacts).then((val: Contact[]) …Run Code Online (Sandbox Code Playgroud) 我在旧系统上运行我的 Ionic 应用程序,该系统不能很好地处理动画,因此我尝试禁用它们。
我尝试opts在创建模态时设置为:
{
cssClass: 'plain-modal',
enableBackdropDismiss: false,
enterAnimation: 'no-animation',
leaveAnimation: 'no-animation',
showBackdrop: true
}
Run Code Online (Sandbox Code Playgroud)
似乎no-animation在这里没有效果。它实际上并不应用于任何 DOM 元素。或者是吗?
在诊断时,我注意到 Ionic.content在模态即将打开或关闭时应用内联 CSS:
transform: translateX(100%);
will-change: transform, -webkit-transform;
transition-duration: 500ms;
transition-timing-function: cubic-bezier(0.36, 0.66, 0.04, 1);
Run Code Online (Sandbox Code Playgroud)
所以我尝试使用以下方法覆盖那些initial !important:
.show-page.plain-modal {
> ion-backdrop {
opacity: 0.5; // Nothing is displayed if I don't do this
}
> .modal-wrapper {
opacity: 1; // Again nothing is displayed if I don't do this
> .ion-page { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用这个构建 ionic android 应用程序部署到设备来构建离子 Android 应用程序
但当我运行此命令时显示错误: apksigner verify HelloWorld.apk
错误:
D:\ionic\demoAds1>apksigner verify HelloWorld.apk
'apksigner' is not recognized as an internal or external command,
operable program or batch file.
D:\ionic\demoAds1>
Run Code Online (Sandbox Code Playgroud)
知道该怎么做吗?
嗨,我已经到处研究并查看了 XCode,但还没有弄清楚。我想为我的 iOS 应用程序创建 venmo 风格的圆角,但 iOS 似乎不遵守我为其设置的 sass 规则。<div class='menu-inner'>...</div>侧面菜单样式由从标签生成的div 类控制<ion-menu>。
我的 sass 规则在浏览器上运行良好,但我惊讶地发现它不适用于本机生产,特别是 iOS。这是我的 sass 规则。
.menu-inner {
border-radius: 0 1.7rem 1.7rem 0!important;
}
Run Code Online (Sandbox Code Playgroud)
这会导致浏览器得到所需的结果。 在镀铬检查器中
然而,在 XCode iOS 12.1 iPhone X 中会导致尖角边缘。 iPhone X模拟器
如何使用 ionic 3 在本机应用程序中使角变圆。
我正在尝试直接从他们的 github 存储库安装一个npm库。图书馆是这样的:
https://github.com/zyra/ionic-image-loader
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我直接安装库时:
npm install --save git+https://github.com/zyra/ionic-image-loader
Run Code Online (Sandbox Code Playgroud)
文件node_modules夹已创建,但DIST文件夹未创建。如果我直接从以下位置安装npm:
npm install --save ionic-image-loader
Run Code Online (Sandbox Code Playgroud)
该DIST文件夹已正确创建。我已经尝试在 ionic 项目的根文件夹上执行命令:
npm run build
Run Code Online (Sandbox Code Playgroud)
但该DIST文件夹未创建。
我究竟做错了什么?
在我的 Ionic3 应用程序中,我计算文件大小如下。
HTML
<div>
<input type="file" accept="*" (change)="onSelect($event)">
<button ion-button (click)="calcSize()">calculate size</button>
</div>
<p>Size: {{ size }}</p>
Run Code Online (Sandbox Code Playgroud)
TS
file: File;
size: number;
onSelect(event: any) {
this.file = event.target.files[0];
}
calcSize() {
this.size = this.file.size;
}
Run Code Online (Sandbox Code Playgroud)
以上代码在 iOS 13.2 以下的所有 Android 设备和 iOS 设备上都能完美运行。
但是在 iOS 设备上从照片库中选择大于 13.2 的size视频时,只有视频文件的值为 0。
但是当从 iCloud Drive 选择视频时效果很好。
任何帮助都受到高度赞赏。
在StackBlitz上查找问题。
我真的需要一些帮助来配置 karma.conf.js 以处理打字稿文件,或者不确定缺少什么或我在这里做错了什么。非常新的单元测试并学习了 Jasmine 框架(在示例中它使用 *.js 和 *.spec.js 文件)但在我的 ionic-angular 项目中它的 *.ts 文件和获取错误(如下所示)。我一直试图弄清楚2天,但无法解决这个问题。任何帮助真的很感激。
[在 Angular 6 (6.1.10) 和 typescript (3.8.+.) 中使用 ionic 3 (ionic-angular 3.9.+) 框架]
我的 tsconfig.json >
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es6"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"src/**/*.spec.ts",
"src/**/__tests__/*.ts"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Run Code Online (Sandbox Code Playgroud)
我的 karma.conf.js >
module.exports = function (config) { …Run Code Online (Sandbox Code Playgroud) ionic3 ×10
angular ×6
typescript ×4
html ×2
ios ×2
javascript ×2
cookies ×1
css ×1
es6-promise ×1
http ×1
ios13.2 ×1
node.js ×1
npm ×1
sass ×1
unit-testing ×1