//图片展示组件
define(['jquery', 'vue'], function ($, Vue) {
    return Vue.component('component-demo-image', {
        template: '<div class="demo_img_body">\
                     <img style="width:100%;height: 100%" :src="thumbnailImg" onerror="this.src=\'/supermarket/pages/demo/images/img-1.png\';this.οnerrοr=null">\
                   </div>',
        props: {
            showImg:{default: ''},
            imgIndex:{default:null},
        },
        data: function () {
            return {
               chooseImg:'',
               isShow:false,
               thumbnailImg:getContextPath() + '/pages/demo/images/img-1.png',
            }
        },
        computed: {

        },
        watch: {
            showImg: function(newValue, oldValue) {
                if (this.showImg.length > 0){
                    this.thumbnailImg = getContextPath() + '/api/file/'+this.showImg;
                }
            }
        },
        created: function () {
            if (this.showImg.length > 0){
                this.thumbnailImg = getContextPath() + '/api/file/'+this.showImg;
            }
        },
        mounted: function () {
        },
        methods: {
            imgerrorfun:function(o){
                var that = this;
                console.log(this.thumbnailImg);
                this.thumbnailImg = getContextPath() + '/pages/demo/images/img-1.png';
                o.onerror=null;
            }
        }
    });
});