mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs(ActionBar): use setup
This commit is contained in:
parent
a4ef370b0d
commit
872bf4ddfb
@ -29,13 +29,17 @@ app.use(ActionBarButton);
|
|||||||
import { Toast } from 'vant';
|
import { Toast } from 'vant';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
setup() {
|
||||||
onClickIcon() {
|
const onClickIcon = () => {
|
||||||
Toast('Click Icon');
|
Toast('Click Icon');
|
||||||
},
|
};
|
||||||
onClickButton() {
|
const onClickButton = () => {
|
||||||
Toast('Click Button');
|
Toast('Click Button');
|
||||||
},
|
};
|
||||||
|
return {
|
||||||
|
onClickIcon,
|
||||||
|
onClickButton,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
@ -29,13 +29,17 @@ app.use(ActionBarButton);
|
|||||||
import { Toast } from 'vant';
|
import { Toast } from 'vant';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
setup() {
|
||||||
onClickIcon() {
|
const onClickIcon = () => {
|
||||||
Toast('点击图标');
|
Toast('点击图标');
|
||||||
},
|
};
|
||||||
onClickButton() {
|
const onClickButton = () => {
|
||||||
Toast('点击按钮');
|
Toast('点击按钮');
|
||||||
},
|
};
|
||||||
|
return {
|
||||||
|
onClickIcon,
|
||||||
|
onClickButton,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
@ -62,43 +62,56 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import { useTranslate } from '@demo/use-translate';
|
||||||
i18n: {
|
import Toast from '../../toast';
|
||||||
'zh-CN': {
|
|
||||||
icon1: '客服',
|
const i18n = {
|
||||||
icon2: '购物车',
|
'zh-CN': {
|
||||||
icon3: '店铺',
|
icon1: '客服',
|
||||||
button1: '加入购物车',
|
icon2: '购物车',
|
||||||
button2: '立即购买',
|
icon3: '店铺',
|
||||||
iconBadge: '徽标提示',
|
button1: '加入购物车',
|
||||||
collected: '已收藏',
|
button2: '立即购买',
|
||||||
clickIcon: '点击图标',
|
iconBadge: '徽标提示',
|
||||||
clickButton: '点击按钮',
|
collected: '已收藏',
|
||||||
customIconColor: '自定义图标颜色',
|
clickIcon: '点击图标',
|
||||||
customButtonColor: '自定义按钮颜色',
|
clickButton: '点击按钮',
|
||||||
},
|
customIconColor: '自定义图标颜色',
|
||||||
'en-US': {
|
customButtonColor: '自定义按钮颜色',
|
||||||
icon1: 'Icon1',
|
|
||||||
icon2: 'Icon2',
|
|
||||||
icon3: 'Icon3',
|
|
||||||
button1: 'Button',
|
|
||||||
button2: 'Button',
|
|
||||||
iconBadge: 'Icon Badge',
|
|
||||||
collected: 'Collected',
|
|
||||||
clickIcon: 'Click Icon',
|
|
||||||
clickButton: 'Click Button',
|
|
||||||
customIconColor: 'Custom Icon Color',
|
|
||||||
customButtonColor: 'Custom Button Color',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
'en-US': {
|
||||||
onClickIcon() {
|
icon1: 'Icon1',
|
||||||
this.$toast(this.t('clickIcon'));
|
icon2: 'Icon2',
|
||||||
},
|
icon3: 'Icon3',
|
||||||
onClickButton() {
|
button1: 'Button',
|
||||||
this.$toast(this.t('clickButton'));
|
button2: 'Button',
|
||||||
},
|
iconBadge: 'Icon Badge',
|
||||||
|
collected: 'Collected',
|
||||||
|
clickIcon: 'Click Icon',
|
||||||
|
clickButton: 'Click Button',
|
||||||
|
customIconColor: 'Custom Icon Color',
|
||||||
|
customButtonColor: 'Custom Button Color',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
|
|
||||||
|
const onClickIcon = () => {
|
||||||
|
Toast(t('clickIcon'));
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClickButton = () => {
|
||||||
|
Toast(t('clickButton'));
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
t,
|
||||||
|
onClickIcon,
|
||||||
|
onClickButton,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user