docs(Swipe): use composition api
This commit is contained in:
+19
-17
@@ -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;
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user