0.0.22 • Published 7 months ago

vue-image-lazy-xg v0.0.22

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

vue-image-lazy-xg

imageLazy component for Vue3

源代码

live demo is here: https://gitee.com/derekgo/tool-collection/tree/master/imageLazyLoading/vue3/pluginVersion/v1

配置

使用imageLazy组件的配置

字段类型默认值描述
srcString""图片源地址,同原生属性一致
imgListString[][]开启图片预览功能
loadingColorString"#2dbff1"加载图标主题颜色
errorColorString"888888"加载图标主题颜色
imgStyleString""图片样式
keyString-Number0图片索引图片索引model,deploymentId,tokensToGenerate(默认值:512),temperature,topP 详情查看:https://uniapp.dcloud.net.cn/uniCloud/uni-ai.html#chat-completion
isShowImgDialogBooleantrue是否显示图片查看弹出框图片索引model,deploymentId,tokensToGenerate(默认值:512),temperature,topP 详情查看:https://uniapp.dcloud.net.cn/uniCloud/uni-ai.html#chat-completion

安装

npm i vue-image-lazy-xg --save

使用

main.ts

// script
import { createApp } from 'vue';
import App from './App.vue';
import imageLazy from "vue-image-lazy-xg"
import "vue-image-lazy-xg/lib/style.css"

const app = createApp(App);
app.use(imageLazy); //全局注册
//配置可有可有无
//app.use(imageLazyLoading,{
//    loadingGif:"加载的图片",
//    errorImg:"错误的图片",
//})
app.mount('#app');

App.vue

第一个写法直接用自定义命令

<template>
  <div class="app-container">
     <img
        class="img"
        v-for="item in result"
        :key="item.picture"
        v-img-lazy="item.picture"
    />
  </div>
</template>

<script setup lang="ts">
import {ref} from "vue";

const result = [
  { picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  { picture:
        '1111111111111',
    picList:[]
  },
  { picture:
        '2222222222222222',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
      "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
      "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  { picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  {
    picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  {
    picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  }]
</script>

第二个写法用组件

<template>
  <div class="app-container">
  <!--默认使用方法-->
   <imageLazy
      :isShowImgDialog="false"
      v-for="(item,key) in result"
      class="img"
      :key="key"
      :src="item.picture"
      :imgList="item?.picList"
       />
       
   <!--自定义错误图标-->
   <imageLazy
                v-for="(item,key) in result"
                class="img"
                :key="key"
                :src="item.picture"
                :lazy="true"
        >
      <template #error>
        <i :style="'font-size:58px;color:red'" class="icon image-lazy-iconfont icon-tupianjiazaishibai"></i>
      </template>
   </imageLazy>
  </div>
</template>

<script setup lang="ts">
import {ref} from "vue";

const result = [
  { picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  { picture:
        '1111111111111',
    picList:[]
  },
  { picture:
        '2222222222222222',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
      "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
      "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  { picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  {
    picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  },
  {
    picture:
        'https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1enjLx.img?w=1920&h=1080&q=60&m=2&f=jpg',
    picList:["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
    "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
    ]
  }]
</script>
0.0.20

7 months ago

0.0.21

7 months ago

0.0.22

7 months ago

0.0.18

7 months ago

0.0.19

7 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago