index.vue 840 Bytes
<template>
  <div>
    <div class="title">
      <p>{{text}}</p>
      <p class="rightText" v-if="pShow" @click="topClick">{{rightText}}</p>
    </div>
  </div> 
</template>
<script>
export default {
  props: ['text', 'pShow', 'rightText'],
  data () {
    return {}
  },
  methods: {
    topClick () {
      this.$emit('topClick')
    }
  }
}
</script>

<style lang="less" scoped>
  .title {
    width: 100%;
    height: 44px;
    background-color: #333;
    position: fixed;
    top: 0;
    left: 0;
    color: #fff;
    font-size: 16px;
    // line-height: 44px;
    text-align: center;
    z-index: 10;
    display: flex;
    align-items: center;
    &>p:first-child {
      line-height: 20px;
      flex: 1;
    }
    .rightText {
      position: absolute;
      top: 0;
      right: 20px;
      line-height: 44px;
    }
  }
</style>