Giter VIP home page Giter VIP logo

wepy-img-loader's Introduction

微信小程序 wepyjs 第三方图片预加载组件

说明

wxapp-img-loader只能用于小程序原生开发,因此需要一个适用于wepy使用的组件。

使用

安装组件

npm install wepy-img-loader --save

引入组件

// index.wpy
<template>
    <imgloader />
</template>
<script>
    import wepy from 'wepy';
    import ImgLoader from 'wepy-img-loader';

    export default class Index extends wepy.page {
        components = {
            imgloader: ImgLoader
        }
    }
</script>

调用方法

//缩略图 80x50 3KB
const imgUrlThumbnail = 'http://storage.360buyimg.com/mtd/home/lion1483683731203.jpg'
//原图 3200x2000 1.6MB
const imgUrlOriginal = 'http://storage.360buyimg.com/mtd/home/lion1483624894660.jpg'

this.msg = '大图正在拼命加载...'
this.imgUrl = imgUrlThumbnail

this.$invoke('imgloader', 'load', imgUrlOriginal, (err, data) => {
    this.msg = '大图加载完成~'
    if (!err) {
    this.imgUrl = data.src
    }
    this.$apply()
})

Thanks

wepy-img-loader's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.