primevue-mirror/doc/button/LoadingDoc.vue

75 lines
1.7 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Busy state is controlled with the <i>loading</i> property.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<Button type="button" label="Search" icon="pi pi-check" :loading="loading" @click="load" />
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
loading: false,
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Button type="button" label="Search" icon="pi pi-search" :loading="loading" @click="load" />`,
options: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex justify-content-center">
<Button type="button" label="Search" icon="pi pi-search" :loading="loading" @click="load" />
</div>
</template>
<script>
export default {
data() {
return {
loading: false
};
},
methods: {
load() {
this.loading = true;
setTimeout(() => {
this.loading = false;
}, 2000);
}
}
};
<\/script>`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex justify-content-center">
<Button type="button" label="Search" icon="pi pi-search" :loading="loading" @click="load" />
</div>
</template>
<script setup>
import { ref } from 'vue';
const loading = ref(false);
const load = () => {
loading.value = true;
setTimeout(() => {
loading.value = false;
}, 2000);
};
<\/script>`
}
};
},
methods: {
load() {
this.loading = true;
setTimeout(() => {
this.loading = false;
}, 2000);
}
}
};
</script>