docs(ContactList): use composition api

This commit is contained in:
chenjiahan
2020-12-13 14:28:02 +08:00
parent 03e65d9427
commit 540ffb6a4c
4 changed files with 102 additions and 81 deletions
+18 -11
View File
@@ -26,11 +26,12 @@ app.use(ContactList);
```
```js
import { reactive } from 'vue';
import { Toast } from 'vant';
export default {
data() {
return {
setup() {
const state = reactive({
chosenContactId: '1',
list: [
{
@@ -45,18 +46,24 @@ export default {
tel: '1310000000',
},
],
};
},
methods: {
onAdd() {
});
const onAdd = () => {
Toast('Add');
},
onEdit(contact) {
};
const onEdit = (contact) => {
Toast('Edit' + contact.id);
},
onSelect(contact) {
};
const onSelect = (contact) => {
Toast('Select' + contact.id);
},
};
return {
state,
onAdd,
onEdit,
onSelect,
};
},
};
```