docs(Stepper): use composition api

This commit is contained in:
chenjiahan
2020-12-08 21:04:27 +08:00
parent 9af0840f36
commit 7e03486501
3 changed files with 63 additions and 41 deletions
+20 -14
View File
@@ -19,11 +19,12 @@ app.use(Stepper);
```
```js
import { ref } from 'vue';
export default {
data() {
return {
value: 1,
};
setup() {
const value = ref(1);
return { value };
},
};
```
@@ -77,24 +78,29 @@ export default {
```
```js
import { ref } from 'vue';
import { Toast } from 'vant';
export default {
data() {
return {
value: 1,
};
},
methods: {
onChange(value) {
setup() {
const value = ref(1);
let timer;
const onChange = (newValue) => {
if (newValue === value.value) {
return;
}
Toast.loading({ forbidClick: true });
clearTimeout(this.timer);
this.timer = setTimeout(() => {
timer = setTimeout(() => {
Toast.clear();
this.value = value;
value.value = newValue;
}, 500);
},
};
return { value };
},
};
```