// 解决图片跨域

    1. //直接读成blob文件对象
    2. getImage:function (url,imgId) {
    3. var xhr = new XMLHttpRequest();
    4. xhr.open('get', url, true);
    5. xhr.responseType = 'blob';
    6. xhr.onload = function () {
    7. if (this.status == 200) {
    8. document.getElementById(imgId).src = URL.createObjectURL(this.response);
    9. }
    10. };
    11. xhr.send(null);
    12. }