primevue-mirror/doc/button/LoadingDoc.vue

78 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-search" :loading="loading" @click="load" />
2023-02-28 08:29:30 +00:00
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
loading: false,
code: {
2023-09-22 12:54:14 +00:00
basic: `
2023-10-15 09:38:39 +00:00
<Button type="button" label="Search" icon="pi pi-search" :loading="loading" @click="load" />
`,
2023-09-22 12:54:14 +00:00
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);
}
}
};
2023-10-15 09:38:39 +00:00
<\/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);
};
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
load() {
this.loading = true;
setTimeout(() => {
this.loading = false;
}, 2000);
}
}
};
</script>