jingrow-ui/docs/components/errormessage.md
jingrow c7bac1a7a0
Some checks failed
Publish on NPM / publish (push) Has been cancelled
Build and Deploy Storybook / build (push) Has been cancelled
Tests / test (push) Has been cancelled
initial commit
2025-10-24 00:40:30 +08:00

1.3 KiB

ErrorMessage

The ErrorMessage component is used to show an error message when an action has failed.

Usage

You can pass an error message as a string to message prop. You can also pass an Error object directly to message prop.

The component won't render if message is falsy. So, you don't have to write the v-if directive.

<template>
  <ErrorMessage message="Task failed successfully" />
  <ErrorMessage :message="error" />
  <ErrorMessage :message="null" />
</template>

<script setup>
import { ErrorMessage } from 'jingrow-ui'

let error = null
try {
  throw new Error('An error occurred')
} catch (e) {
  error = e
}
</script>

Props

Name Default Value Description
message null String | Error Message to show as error