mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
docs(NavBar): use setup
This commit is contained in:
parent
872bf4ddfb
commit
775f0bef47
@ -22,10 +22,13 @@ app.use(ContactCard);
|
||||
import { Toast } from 'vant';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
onAdd() {
|
||||
setup() {
|
||||
const onAdd = () => {
|
||||
Toast('add');
|
||||
},
|
||||
};
|
||||
return {
|
||||
onAdd,
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -26,10 +26,13 @@ app.use(ContactCard);
|
||||
import { Toast } from 'vant';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
onAdd() {
|
||||
setup() {
|
||||
const onAdd = () => {
|
||||
Toast('新增');
|
||||
},
|
||||
};
|
||||
return {
|
||||
onAdd,
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -29,13 +29,17 @@ app.use(NavBar);
|
||||
import { Toast } from 'vant';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
onClickLeft() {
|
||||
setup() {
|
||||
const onClickLeft = () => {
|
||||
Toast('Back');
|
||||
},
|
||||
onClickRight() {
|
||||
};
|
||||
const onClickRight = () => {
|
||||
Toast('Button');
|
||||
},
|
||||
};
|
||||
return {
|
||||
onClickLeft,
|
||||
onClickRight,
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -29,13 +29,17 @@ app.use(NavBar);
|
||||
import { Toast } from 'vant';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
onClickLeft() {
|
||||
setup() {
|
||||
const onClickLeft = () => {
|
||||
Toast('返回');
|
||||
},
|
||||
onClickRight() {
|
||||
};
|
||||
const onClickRight = () => {
|
||||
Toast('按钮');
|
||||
},
|
||||
};
|
||||
return {
|
||||
onClickLeft,
|
||||
onClickRight,
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -19,24 +19,36 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
useSlot: '使用插槽',
|
||||
},
|
||||
'en-US': {
|
||||
useSlot: 'Use Slot',
|
||||
},
|
||||
},
|
||||
<script lang="ts">
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
import Toast from '../../toast';
|
||||
|
||||
methods: {
|
||||
onClickLeft() {
|
||||
this.$toast(this.t('back'));
|
||||
},
|
||||
onClickRight() {
|
||||
this.$toast(this.t('button'));
|
||||
},
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
useSlot: '使用插槽',
|
||||
},
|
||||
'en-US': {
|
||||
useSlot: 'Use Slot',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
|
||||
const onClickLeft = () => {
|
||||
Toast(t('back'));
|
||||
};
|
||||
|
||||
const onClickRight = () => {
|
||||
Toast(t('button'));
|
||||
};
|
||||
|
||||
return {
|
||||
t,
|
||||
onClickLeft,
|
||||
onClickRight,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user