2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>Multiple messages can be displayed using the standard v-for directive.</p>
|
|
|
|
</DocSectionText>
|
|
|
|
<div class="card">
|
|
|
|
<Button label="Show" @click="addMessages()" />
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button label="Clear" severity="secondary" class="ml-2" @click="clearMessages()" />
|
2023-02-28 08:29:30 +00:00
|
|
|
<transition-group name="p-message" tag="div">
|
|
|
|
<Message v-for="msg of messages" :key="msg.id" :severity="msg.severity">{{ msg.content }}</Message>
|
|
|
|
</transition-group>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
messages: [],
|
|
|
|
count: 0,
|
|
|
|
code: {
|
2023-08-16 13:58:31 +00:00
|
|
|
basic: `<Button label="Show" @click="addMessages()" />
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button label="Clear" severity="secondary" class="ml-2" @click="clearMessages()" />
|
|
|
|
<transition-group name="p-message" tag="div">
|
|
|
|
<Message v-for="msg of messages" :key="msg.id" :severity="msg.severity">{{ msg.content }}</Message>
|
|
|
|
</transition-group>`,
|
2023-08-16 13:58:31 +00:00
|
|
|
options: `<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button label="Show" @click="addMessages()" />
|
|
|
|
<Button label="Clear" severity="secondary" class="ml-2" @click="clearMessages()" />
|
|
|
|
<transition-group name="p-message" tag="div">
|
|
|
|
<Message v-for="msg of messages" :key="msg.id" :severity="msg.severity">{{ msg.content }}</Message>
|
|
|
|
</transition-group>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
messages: [],
|
|
|
|
count: 0
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addMessages() {
|
|
|
|
this.messages = [
|
|
|
|
{ severity: 'info', content: 'Dynamic Info Message', id: this.count++ },
|
|
|
|
{ severity: 'success', content: 'Dynamic Success Message', id: this.count++ },
|
|
|
|
{ severity: 'warn', content: 'Dynamic Warning Message', id: this.count++ }
|
|
|
|
];
|
|
|
|
},
|
|
|
|
clearMessages() {
|
|
|
|
this.messages = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
<\/script>`,
|
2023-08-16 13:58:31 +00:00
|
|
|
composition: `<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button label="Show" @click="addMessages()" />
|
|
|
|
<Button label="Clear" severity="secondary" class="ml-2" @click="clearMessages()" />
|
|
|
|
<transition-group name="p-message" tag="div">
|
|
|
|
<Message v-for="msg of messages" :key="msg.id" :severity="msg.severity">{{ msg.content }}</Message>
|
|
|
|
</transition-group>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
|
const messages = ref([]);
|
|
|
|
let count = ref(0);
|
|
|
|
|
|
|
|
const addMessages = () => {
|
|
|
|
messages.value = [
|
|
|
|
{ severity: 'info', content: 'Dynamic Info Message', id: count.value++ },
|
|
|
|
{ severity: 'success', content: 'Dynamic Success Message', id: count.value++ },
|
|
|
|
{ severity: 'warn', content: 'Dynamic Warning Message', id: count.value++ }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
const clearMessages = () => {
|
|
|
|
messages.value = [];
|
|
|
|
};
|
|
|
|
<\/script>`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addMessages() {
|
|
|
|
this.messages = [
|
|
|
|
{ severity: 'info', content: 'Dynamic Info Message', id: this.count++ },
|
|
|
|
{ severity: 'success', content: 'Dynamic Success Message', id: this.count++ },
|
|
|
|
{ severity: 'warn', content: 'Dynamic Warning Message', id: this.count++ }
|
|
|
|
];
|
|
|
|
},
|
|
|
|
clearMessages() {
|
|
|
|
this.messages = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|