Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nz-avatar] 增加图片加载错误或者预加载显示默认图片属性 #3223

Closed
DreamPWJ opened this issue Apr 5, 2019 · 0 comments

Comments

@DreamPWJ
Copy link
Contributor

commented Apr 5, 2019

What problem does this feature solve?

当图片还没有加载完成之前显示默认图片 如果图片加载失败 显示默认图片
已经使用指令对img的做了统一处理 但是nz-avatar无法生效
代码如下
@directive({
selector: 'img[default],img',
host: {
'[src]': 'src',
'(load)': 'load()',
'(error)': 'error()'
}
})
export class ImagePreloadDirective {
@input() src: string;
@input() default: string;
@HostBinding('class') className;

constructor() {
}

error() {
this.src = this.default ? this.default : 'assets/img/logo.png';
}

load() {
this.className = 'image-loaded';
}

}

What does the proposed API look like?

[nzDefault]='默认图片地址';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.