docs(Swipe): use composition api

This commit is contained in:
chenjiahan
2020-12-09 10:13:07 +08:00
parent 6150e21f4a
commit d297807f55
3 changed files with 63 additions and 51 deletions
+19 -17
View File
@@ -50,13 +50,12 @@ Use `lazy-render` prop to enable lazy rendering.
```js
export default {
data() {
return {
images: [
'https://img.yzcdn.cn/vant/apple-1.jpg',
'https://img.yzcdn.cn/vant/apple-2.jpg',
],
};
setup() {
const images = [
'https://img.yzcdn.cn/vant/apple-1.jpg',
'https://img.yzcdn.cn/vant/apple-2.jpg',
];
return { images };
},
};
```
@@ -76,10 +75,11 @@ export default {
import { Toast } from 'vant';
export default {
methods: {
onChange(index) {
setup() {
const onChange = (index) => {
Toast('Current Swipe index:' + index);
},
};
return { onChange };
},
};
```
@@ -134,16 +134,18 @@ export default {
```
```js
import { ref } from 'vue';
export default {
data() {
setup() {
const current = ref(0);
const onChange = (index) => {
current.value = index;
};
return {
current: 0,
current,
onChange,
};
},
methods: {
onChange(index) {
this.current = index;
},
},
};
```