mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
docs(vue): update component usage examples for vue 3 (#22050)
This commit is contained in:
@ -212,35 +212,38 @@ export class LoadingExample {
|
||||
|
||||
```html
|
||||
<template>
|
||||
<IonVuePage :title="'Loading'">
|
||||
<ion-button @click="presentLoading">Show Loading</ion-button>
|
||||
<br />
|
||||
<ion-button @click="presentLoadingWithOptions">Show Loading</ion-button>
|
||||
</IonVuePage>
|
||||
<ion-button @click="presentLoading">Show Loading</ion-button>
|
||||
<br />
|
||||
<ion-button @click="presentLoadingWithOptions">Show Loading</ion-button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
<script>
|
||||
import { IonButton, loadingController } from '@ionic/vue';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
timeout: { type: Number, default: 1000 },
|
||||
},
|
||||
methods: {
|
||||
presentLoading() {
|
||||
return this.$ionic.loadingController
|
||||
async presentLoading() {
|
||||
const loading = await loadingController
|
||||
.create({
|
||||
cssClass: 'my-custom-class',
|
||||
message: 'Please wait...',
|
||||
duration: this.timeout,
|
||||
})
|
||||
.then(loading => {
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout)
|
||||
return loading.present()
|
||||
})
|
||||
});
|
||||
|
||||
await loading.present();
|
||||
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout);
|
||||
},
|
||||
presentLoadingWithOptions() {
|
||||
return this.$ionic.loadingController
|
||||
async presentLoadingWithOptions() {
|
||||
const loading = await loadingController
|
||||
.create({
|
||||
spinner: null,
|
||||
duration: this.timeout,
|
||||
@ -248,16 +251,17 @@ export default {
|
||||
translucent: true,
|
||||
cssClass: 'custom-class custom-loading',
|
||||
backdropDismiss: true
|
||||
})
|
||||
.then(loading=> {
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout)
|
||||
return loading.present()
|
||||
})
|
||||
});
|
||||
|
||||
await loading.present();
|
||||
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout);
|
||||
},
|
||||
},
|
||||
}
|
||||
components: { IonButton }
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@ -1,34 +1,37 @@
|
||||
```html
|
||||
<template>
|
||||
<IonVuePage :title="'Loading'">
|
||||
<ion-button @click="presentLoading">Show Loading</ion-button>
|
||||
<br />
|
||||
<ion-button @click="presentLoadingWithOptions">Show Loading</ion-button>
|
||||
</IonVuePage>
|
||||
<ion-button @click="presentLoading">Show Loading</ion-button>
|
||||
<br />
|
||||
<ion-button @click="presentLoadingWithOptions">Show Loading</ion-button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
<script>
|
||||
import { IonButton, loadingController } from '@ionic/vue';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
timeout: { type: Number, default: 1000 },
|
||||
},
|
||||
methods: {
|
||||
presentLoading() {
|
||||
return this.$ionic.loadingController
|
||||
async presentLoading() {
|
||||
const loading = await loadingController
|
||||
.create({
|
||||
cssClass: 'my-custom-class',
|
||||
message: 'Please wait...',
|
||||
duration: this.timeout,
|
||||
})
|
||||
.then(loading => {
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout)
|
||||
return loading.present()
|
||||
})
|
||||
});
|
||||
|
||||
await loading.present();
|
||||
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout);
|
||||
},
|
||||
presentLoadingWithOptions() {
|
||||
return this.$ionic.loadingController
|
||||
async presentLoadingWithOptions() {
|
||||
const loading = await loadingController
|
||||
.create({
|
||||
spinner: null,
|
||||
duration: this.timeout,
|
||||
@ -36,15 +39,16 @@ export default {
|
||||
translucent: true,
|
||||
cssClass: 'custom-class custom-loading',
|
||||
backdropDismiss: true
|
||||
})
|
||||
.then(loading=> {
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout)
|
||||
return loading.present()
|
||||
})
|
||||
});
|
||||
|
||||
await loading.present();
|
||||
|
||||
setTimeout(function() {
|
||||
loading.dismiss()
|
||||
}, this.timeout);
|
||||
},
|
||||
},
|
||||
}
|
||||
components: { IonButton }
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user