docs(ImagePreview): use composition api

This commit is contained in:
chenjiahan
2020-12-09 14:48:44 +08:00
parent 9fbda243cf
commit 3d05e56195
3 changed files with 55 additions and 35 deletions
+12 -7
View File
@@ -88,22 +88,27 @@ setTimeout(() => {
```
```js
import { reactive, toRefs } from 'vue';
export default {
data() {
return {
setup() {
const state = reactive({
show: false,
index: 0,
});
const onChange = (index) => {
state.index = index;
};
return {
...toRefs(state),
images: [
'https://img.yzcdn.cn/vant/apple-1.jpg',
'https://img.yzcdn.cn/vant/apple-2.jpg',
],
onChange,
};
},
methods: {
onChange(index) {
this.index = index;
},
},
};
```