图片选择器 :

适当时刻调用选择器方法

<div id='test'></div>
<!--PS: 禁止在此div标签内写任何代码,因为调用插件后,会覆盖掉标签内的东西-->

单图上传

$('#test').click(function () {
    $.SingleImageSelector({
        confirm: function (image) {
            console.log('image-->', image)
                      // 回调函数,image为图片相关数据
        }
    });
})

image数据示例:

{
    "image_url": "http://127.0.0.1:8081/javashop/statics/attachment/2017/8/23/15/54520593.jpg",
    "op_type": "link",
    "op_value": "",
    "op_detail": ""
}

多图上传

// 只需添加fileNumLimit参数即可,其余同上

$('#test').SingleImageSelector({
       fileNumLimit: 10,
    confirm: function (images) {
            // 此时iamges为对象数组
        console.log('image-->', images)
    }
});

PS: JS文件在header.html中被引用

results matching ""

    No results matching ""