Showing
2 changed files
with
12 additions
and
7 deletions
@@ -4,9 +4,11 @@ | @@ -4,9 +4,11 @@ | ||
4 | * @date: 2015/11/12 | 4 | * @date: 2015/11/12 |
5 | */ | 5 | */ |
6 | var $ = require('jquery'); | 6 | var $ = require('jquery'); |
7 | +var $userAvatar = $('.user-avatar'); | ||
8 | +var myImage = new Image(); | ||
7 | 9 | ||
8 | require('../product/recommend-for-you.js'); | 10 | require('../product/recommend-for-you.js'); |
9 | - | ||
10 | -$('.user-avatar').on('error', function() { | ||
11 | - $(this).attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); | ||
12 | -}); | ||
11 | +myImage.src = $userAvatar.attr('src'); | ||
12 | +myImage.onerror = function() { | ||
13 | + $userAvatar.attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); | ||
14 | +}; |
@@ -4,7 +4,10 @@ | @@ -4,7 +4,10 @@ | ||
4 | * @date: 2015/11/19 | 4 | * @date: 2015/11/19 |
5 | */ | 5 | */ |
6 | var $ = require('jquery'); | 6 | var $ = require('jquery'); |
7 | +var $userAvatar = $('.user-avatar'); | ||
8 | +var myImage = new Image(); | ||
7 | 9 | ||
8 | -$('.user-avatar').on('error', function() { | ||
9 | - $(this).attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); | ||
10 | -}); | ||
10 | +myImage.src = $userAvatar.attr('src'); | ||
11 | +myImage.onerror = function() { | ||
12 | + $userAvatar.attr('src', 'http://static.dev.yohobuy.com/img/me/index/user-avatar.png'); | ||
13 | +}; |
-
Please register or login to post a comment