We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
loadImg(src) { return new Promise((resolve, reject) => { let img = new Image() img.onload = () => resolve(img) img.onerror = reject img.src = src }) },
对于vue
<img :src='src1' ref="testImg1"> <img :src='src2' ref="testImg2"> data() { return { src1: 'http://one.com/avatar1.png', src2: 'http://one.com/avatar2.png' } }, methods: { init() { const refImg1 = this.$refs.testImg1 const refImg2 = this.$refs.testImg2 Promise.all([ this.loadImg(refImg1, this.src1 ), this.loadImg(refImg2, this.src2 ), ]).then(res => { console.log('---图片均已加载完毕---') }) }, loadImg(refImg, src) { return new Promise((resolve, reject) => { refImg.onload = () => resolve(refImg) refImg.onerror = reject refImg.src = src }) }, }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
对于vue
The text was updated successfully, but these errors were encountered: