介绍
本文档主要用于描述 ShadcnMessage
组件的一些特性和用法。
用法
查看代码
vue
<template>
<ShadcnButton @click="handleClick">Show Message</ShadcnButton>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
methods: {
handleClick() {
this.$Message.info({
content: 'This is an info message',
duration: 2
})
}
}
})
显示图标 (show-icon)
查看代码
vue
<template>
<ShadcnButton @click="handleClick">Show Message</ShadcnButton>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
methods: {
handleClick() {
this.$Message.info({
content: 'This is an info message',
showIcon: true
})
}
}
})
类型 (type)
查看代码
vue
<template>
<ShadcnSpace wrap>
<ShadcnButton @click="info">Info</ShadcnButton>
<ShadcnButton @click="success">Success</ShadcnButton>
<ShadcnButton @click="warning">Warning</ShadcnButton>
<ShadcnButton @click="error">Error</ShadcnButton>
<ShadcnButton @click="loading">Loading</ShadcnButton>
</ShadcnSpace>
</template>
<script>
export default {
methods: {
info() {
this.$Message.info({
content: 'This is an info tip',
type: 'info',
showIcon: true
});
},
success() {
this.$Message.success({
content: 'This is a success tip',
type: 'success',
showIcon: true
});
},
warning() {
this.$Message.warning({
content: 'This is a warning tip',
type: 'warning',
showIcon: true
});
},
error() {
this.$Message.error({
content: 'This is an error tip',
type: 'error',
showIcon: true
});
},
loading() {
this.$Message.loading({
content: 'This is a loading tip',
type: 'loading',
showIcon: true
});
}
}
}
</script>
背景色 (background)
查看代码
vue
<template>
<ShadcnSpace wrap>
<ShadcnButton @click="info">Info</ShadcnButton>
<ShadcnButton @click="success">Success</ShadcnButton>
<ShadcnButton @click="warning">Warning</ShadcnButton>
<ShadcnButton @click="error">Error</ShadcnButton>
<ShadcnButton @click="loading">Loading</ShadcnButton>
</ShadcnSpace>
</template>
<script>
export default {
methods: {
info() {
this.$Message.info({
content: 'This is an info tip',
type: 'info',
showIcon: true,
background: true
});
},
success() {
this.$Message.success({
content: 'This is a success tip',
type: 'success',
showIcon: true,
background: true
});
},
warning() {
this.$Message.warning({
content: 'This is a warning tip',
type: 'warning',
showIcon: true,
background: true
});
},
error() {
this.$Message.error({
content: 'This is an error tip',
type: 'error',
showIcon: true,
background: true
});
},
loading() {
this.$Message.loading({
content: 'This is a loading tip',
type: 'loading',
showIcon: true,
background: true
});
}
}
}
</script>
可关闭 (closable)
查看代码
vue
<template>
<ShadcnButton @click="closable">Show Message</ShadcnButton>
</template>
<script>
export default {
methods: {
closable() {
this.$Message.info({
content: 'This is an info tip',
type: 'info',
showIcon: true,
closable: true
})
}
}
}
</script>