1.0.1 • Published 4 years ago

choose-images v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

choose-images

simple choose image video audio file

Install

npm install --save choose-images

Usage

For vue-cli user:

import choose from 'choose-images'

For standalone usage:

<script src="../../src/index.js" type="module"></script>

Sample

<body>
    <div id="app">
        <button v-on:click="chooseImage">choose video</button>
        <h1>获取到的图片信息:{{images}}</h1>
    </div>
</body>
<script type="text/javascript" src="https://unpkg.com/vue"></script>
<script type="module">
    import choose from '../../src/index.js'
    new Vue({
        el: "#app",
        data: {
            images: ''
        },
        methods: {
            chooseImage: async function () {
                const res = await choose({ type: 'video' })
                this.images = JSON.stringify(res)
            }
        }
    })
</script>

Sample 2

<body>
    <button id='btn'>choose images</button>
</body>
<script src="../../src/index.js" type="module"></script>
<script type="module">
    document.getElementById('btn').onclick = function () {
        choose({
            type = 'image',
            sourceType = ['album', 'camera'],
            count = 9,
            inputId = 'inputId'
        })
            .then(res => {
                console.log(res)
                document.body.append(JSON.stringify(res))
            })
            .catch(err => {
                console.log(err)
            })
    }
</script>

Remarks

html5 most Android multi file selections are not supported.

more infomation

(MDN Web)https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input