Skip to content

XQrCode 操作按钮

实现 基于 VueQrcode

示例

基础用法

<template>
  <div class="page">
    <XQrCode :size="100" :content="contentLoader" tip="请刷新"></XQrCode>

    <XQrCode
      :size="120"
      :content="contentLoader"
      :expired="2000"
      tip="请刷新"></XQrCode>

    <XQrCode
      :size="150"
      :content="contentLoader"
      :expired="5000"
      tip="请刷新一下"></XQrCode>
  </div>
</template>

<script setup lang="ts">
  import { XQrCode } from '@vtj/ui';

  const contentLoader: any = () => {
    return 'abc' + Date.now();
  };
</script>

<style scoped>
  .page {
    display: flex;
    gap: 30px;
  }
</style>

options 用法

<template>
  <div class="page">
    <XQrCode :size="100" :content="contentLoader" tip="请刷新"></XQrCode>

    <XQrCode
      :size="100"
      :content="contentLoader"
      tip="请刷新"
      :options="qrcodeOptions"></XQrCode>
  </div>
</template>

<script setup lang="ts">
  import { XQrCode } from '@vtj/ui';
  const contentLoader: any = () => {
    return 'abc' + Date.now();
  };

  const qrcodeOptions: any = {
    version: 2,
    errorCorrectionLevel: 'H',
    maskPattern: 7,
    margin: 2,
    scale: 2,
    type: 'image/jpeg',
    color: { dark: '#000000ff', light: '#ffffffff' },
    quality: 0.99
  };
</script>

<style scoped>
  .page {
    display: flex;
    gap: 30px;
  }
</style>

API

属性

属性名说明类型默认值
size二维码尺寸number-
content二维码内容string-
expired过期时间number-
tip提示文本string-
optionsqrcode 配置参数object-

options 属性配置

参数type (range)default value
versionnumber (1-40)N/A
errorCorrectionLevelString ('low', 'medium', 'quartile', 'high', 'L', 'M', 'Q', 'H')'M'
maskPatternnumber (0-7)N/A
toSJISFuncFunctionN/A
marginnumber4
scalenumber4
widthnumberN/A
color{ dark: string; light:string }{ dark: '#000000ff', light: '#ffffffff' }
typestring ('image/png', 'image/jpeg', 'image/webp')'image/png'
qualitynumber(0-1)0.92
valuestring |Array<{ data: string; mode?: string }>N/A

暴露

名称说明类型
refresh刷新-

Released under the MIT License.