Header.vue 687 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <div class="header">
  3. <a-dropdown>
  4. <a-icon type="global" />
  5. <a-menu
  6. slot="overlay"
  7. @click="localeChange"
  8. :selectedKeys="[$route.query.locale || 'zhCN']"
  9. >
  10. <a-menu-item key="zhCN">
  11. 中文
  12. </a-menu-item>
  13. <a-menu-item key="enUS">
  14. English
  15. </a-menu-item>
  16. </a-menu>
  17. </a-dropdown>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. methods: {
  23. localeChange({ key }) {
  24. this.$router.push({ query: { ...this.$route.query, locale: key } });
  25. this.$i18n.locale = key;
  26. }
  27. }
  28. };
  29. </script>
  30. <style scoped>
  31. .header {
  32. float: right;
  33. margin-right: 30px;
  34. }
  35. </style>