Skip to content

v-empty

Function Introduction

Used to display empty status

Example

Presentation data

Usage

typescript
<script setup lang="ts">
import { ref,computed } from 'vue'

const isEmpty = ref(true)
const emptyValue = computed(() => ({
  content: 'No data available',
  img: 'https://th.bing.com/th/id/R.63041927f4a82c69be9154fe7be5dcd8?rik=rEmOJUuEAW8hPQ&riu=http%3a%2f%2fpic.bizhi360.com%2fbbpic%2f22%2f1522.jpg&ehk=yPnRjbJRaymFBmY2UhpFn2DPanf0HBpPLctjo3h3vRA%3d&risl=&pid=ImgRaw&r=0',
  visible: isEmpty.value,
}))
</script>

<template>
  <button @click="isEmpty = !isEmpty">Switching state</button>
  <div :style="{
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
    height: '200px',
    width: '200px',
    borderRadius: '5px',
    background: 'blue',
  }" v-empty="emptyValue">Presentation data</div>
</template>

Rule

v-empty receives an object (accepting reactive data) with the following properties:

TypeThe defaultDescription
contentstring'暂无数据'can be empty
imgurl-Image address. The value can be empty
visiblebooleanfalseWhether to display. The value can be empty

Released under the MIT License.