sider.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <el-menu ref="menu" default-active="0" class="nav-menu" v-bind="themeStyles" :collapse="isCollapse" :router="false">
  3. <naf-menu-item
  4. v-for="(item, idx) in menuItems"
  5. :key="idx"
  6. :index="idx.toString()"
  7. :title="item.title"
  8. :options="item.options"
  9. :children="item.children"
  10. :target="item.target"
  11. :prefix="routerPrefix"
  12. >
  13. </naf-menu-item>
  14. </el-menu>
  15. </template>
  16. <script>
  17. import NafMenuItem from './menu-item';
  18. export default {
  19. components: {
  20. NafMenuItem,
  21. },
  22. props: {
  23. theme: String,
  24. isCollapse: Boolean,
  25. menuItems: Array,
  26. routerPrefix: { type: String, default: '' },
  27. },
  28. data() {
  29. return {
  30. msg: 'Use Vue 2.0 Today!',
  31. // menus,
  32. };
  33. },
  34. // mounted: function() {
  35. // this.$nextTick(_ => {
  36. // // Code that will run only after the
  37. // // entire view has been rendered
  38. // this.$refs.menu.open('0');
  39. // });
  40. // },
  41. computed: {
  42. // 计算属性的 getter
  43. themeStyles() {
  44. // `this` 指向 vm 实例
  45. if (this.theme === 'dark') {
  46. // dark styles
  47. return {
  48. backgroundColor: '#545c64',
  49. textColor: '#fff',
  50. activeTextColor: '#ffd04b',
  51. };
  52. }
  53. // default styles
  54. return {
  55. backgroundColor: undefined,
  56. textColor: undefined,
  57. activeTextColor: undefined,
  58. };
  59. },
  60. },
  61. };
  62. </script>
  63. <style lang="less" scoped></style>