575219ee5f2597a5a9d83059a6e3d6136913037c.svn-base 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <el-dropdown class="lang-switch" placement="top" @command="handleCommand">
  3. <span class="lang-label">{{ langObj.label }}</span>
  4. <el-dropdown-menu slot="dropdown">
  5. <el-dropdown-item v-for="langItem in langList" :key="langItem.key" :command="langItem.key">
  6. {{ langItem.label }}
  7. </el-dropdown-item>
  8. </el-dropdown-menu>
  9. </el-dropdown>
  10. </template>
  11. <script>
  12. import { langList } from '@/lang'
  13. export default {
  14. data() {
  15. return {
  16. langList
  17. }
  18. },
  19. computed: {
  20. lang: {
  21. get() {
  22. return this.$store.state.app.lang
  23. },
  24. set(value) {
  25. this.$store.commit('app/SET_LANG', value)
  26. }
  27. },
  28. langObj() {
  29. return this.langList.find(item => item.key === this.lang)
  30. }
  31. },
  32. methods: {
  33. handleCommand(command) {
  34. this.lang = command
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .lang-switch {
  41. position: fixed;
  42. bottom: 100px;
  43. right: 25px;
  44. z-index: 99;
  45. .lang-label {
  46. display: inline-block;
  47. text-align: center;
  48. width: 50px;
  49. height: 50px;
  50. border-radius: 50%;
  51. cursor: pointer;
  52. box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  53. line-height: 50px;
  54. color: #205cd8;
  55. }
  56. }
  57. </style>