{"action":"created","issue":{"url":"https://api.github.com/repos/think2011/localResizeIMG/issues/59","labels_url":"https://api.github.com/repos/think2011/localResizeIMG/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/think2011/localResizeIMG/issues/59/comments","events_url":"https://api.github.com/repos/think2011/localResizeIMG/issues/59/events","html_url":"https://github.com/think2011/localResizeIMG/issues/59","id":119359338,"number":59,"title":"不能预览图片","user":{"login":"zwl1619","id":13177997,"avatar_url":"https://avatars.githubusercontent.com/u/13177997?v=3","gravatar_id":"","url":"https://api.github.com/users/zwl1619","html_url":"https://github.com/zwl1619","followers_url":"https://api.github.com/users/zwl1619/followers","following_url":"https://api.github.com/users/zwl1619/following{/other_user}","gists_url":"https://api.github.com/users/zwl1619/gists{/gist_id}","starred_url":"https://api.github.com/users/zwl1619/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zwl1619/subscriptions","organizations_url":"https://api.github.com/users/zwl1619/orgs","repos_url":"https://api.github.com/users/zwl1619/repos","events_url":"https://api.github.com/users/zwl1619/events{/privacy}","received_events_url":"https://api.github.com/users/zwl1619/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-11-29T12:59:20Z","updated_at":"2015-12-05T05:58:53Z","closed_at":"2015-12-05T05:58:53Z","body":"这样写的代码，但不能预览图片，怎么的？\r\n1、引入js\r\n`<script src=\"/js/dist/lrz.bundle.js\"></script>`\r\n2、view\r\n```<div id=\"upload-container\" class=\"col-xs-12 text-center\">\r\n   <input onchange=\"upload().bind(this)\" type=\"file\" accept=\"image/*\" />\r\n</div>```\r\n3、script\r\n```\r\nfunction upload () {\r\n    lrz(this.files[0])\r\n        .then(function (rst) {\r\n        var img = new Image(),\r\n            div = document.createElement('div'),\r\n            p = document.createElement('p'),\r\n            sourceSize = toFixed2(that.files[0].size / 1024),\r\n            resultSize = toFixed2(rst.fileLen / 1024),\r\n            scale = parseInt(100 - (resultSize / sourceSize * 100));\r\n\r\n        p.style.fontSize = 13 + 'px';\r\n        p.innerHTML      = '源文件：<span class=\"text-danger\">' +\r\n            sourceSize + 'KB' +\r\n            '</span> <br />' +\r\n            '压缩后传输大小：<span class=\"text-success\">' +\r\n            resultSize + 'KB (省' + scale + '%)' +\r\n            '</span> ';\r\n\r\n        div.className = 'col-sm-6';\r\n        div.appendChild(img);\r\n        div.appendChild(p);\r\n\r\n        img.onload = function () {\r\n            document.querySelector('#upload-container').appendChild(div);\r\n        };\r\n\r\n        img.src = rst.base64;\r\n        return rst;\r\n    })\r\n        .catch(function (err) {\r\n           alert(err);\r\n        })\r\n        .always(function () {\r\n            \r\n        });\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/think2011/localResizeIMG/issues/comments/162148063","html_url":"https://github.com/think2011/localResizeIMG/issues/59#issuecomment-162148063","issue_url":"https://api.github.com/repos/think2011/localResizeIMG/issues/59","id":162148063,"user":{"login":"think2011","id":3961388,"avatar_url":"https://avatars.githubusercontent.com/u/3961388?v=3","gravatar_id":"","url":"https://api.github.com/users/think2011","html_url":"https://github.com/think2011","followers_url":"https://api.github.com/users/think2011/followers","following_url":"https://api.github.com/users/think2011/following{/other_user}","gists_url":"https://api.github.com/users/think2011/gists{/gist_id}","starred_url":"https://api.github.com/users/think2011/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/think2011/subscriptions","organizations_url":"https://api.github.com/users/think2011/orgs","repos_url":"https://api.github.com/users/think2011/repos","events_url":"https://api.github.com/users/think2011/events{/privacy}","received_events_url":"https://api.github.com/users/think2011/received_events","type":"User","site_admin":false},"created_at":"2015-12-05T05:58:53Z","updated_at":"2015-12-05T05:58:53Z","body":"还有问题请重新开启"}}