App.vue 2.9 KB
<template>
  <div id="app">
    <mu-drawer :open.sync="side_show" :docked="docked" :right="position === 'right'" :z-depth="1">
      <mu-list>
        <mu-list-item v-for="(v, k) in side_menu" :key="k" button>
          <mu-list-item-title>{{ v.title }}</mu-list-item-title>
        </mu-list-item>
        <!-- <mu-list-item  @click="close" button>
          <mu-list-item-title>Close</mu-list-item-title>
        </mu-list-item> -->
      </mu-list>
    </mu-drawer>
    <mu-appbar :class="['mu-appbar-header', {'is-open': side_show}]" color="primary">
      <mu-button v-if="!side_show" @click="side_show = !side_show" icon slot="left">
        <mu-icon value="menu"></mu-icon>
      </mu-button>
      <p style="text-align: left;">Title</p>
      <mu-button flat slot="right">LOGIN</mu-button>
    </mu-appbar>
    <!-- <mu-row gutter>
      <mu-col span="4" sm="0" md="3" lg="2" xl="2">
        <side :show="show2"></side>
        123
      </mu-col>
      <mu-col span="8" sm="12" md="9" lg="10" xl="10">
        <mu-appbar style="width: 100%;" color="primary">
          <mu-button icon slot="left">
            <mu-icon value="menu"></mu-icon>
          </mu-button>
          Title

          <mu-button flat slot="right">LOGIN</mu-button>
        </mu-appbar>
        <p>111</p>
        <router-view/>
      </mu-col>
    </mu-row> -->
    <div style="left: 256px; top: 100px; position: relative; width: calc(100% - 256px)">
      <router-view/>
    </div>
  </div>
</template>

<script>
// import side from 'components/side'

export default {
  components: {
    // side
  },
  mounted () {
    // 屏幕宽度小于600隐藏侧边栏
    if ($('body').width() <= 600) {
      this.side_show = false;
      this.docked = false;
    } else {
      this.side_show = true;
      this.docked = true;
    }
    // 键盘屏幕宽度
    $(window).resize(() => {
      this.screen_width = $('body').width();
      // 屏幕宽度小于600隐藏侧边栏
      if (this.screen_width <= 600) {
        this.side_show = false;
        this.docked = false;
      } else {
        this.side_show = true;
        this.docked = true;
      }
    });
  },
  data () {
    return {
      side_show: false,
      screen_width: '',
      docked: false,
      position: 'left',
      side_menu: [{
        title: 'Menu Item 1'
      }, {
        title: 'Menu Item 2'
      }]
    }
  },
  methods: {
    close () {
      // 关闭侧边栏
      this.side_show = false;
      $(window).resize()
    }
  }
}
</script>

<style lang="less">
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

.mu-appbar-header {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 101;
    overflow: hidden
}

.mu-appbar-header.is-open {
    left: 256px;
}

.mu-appbar-header.is-only-title .mu-appbar-title {
    margin-left: 16px
}

</style>