<template>
  <div v-if="reload"
       class="avue-code"
       :style="{height: this.height + 'px'}">
    <pre v-highlight>
          <code class="javascript" >{{modelValue}}</code>
      </pre>
  </div>

</template>

<script>
export default {
  props: {
    modelValue: String,
    height: [String, Number]
  },
  data () {
    return {
      reload: true
    }
  },
  watch: {
    modelValue: {
      handler () {
        this.reload = false;
        this.$nextTick(() => {
          this.reload = true;
        })
      },
      deep: true
    },
  }
}
</script>

<style lang="scss">
.avue-code {
  margin: 10px 0;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  overflow-y: scroll;
  background: #282c34;
  pre {
    height: auto;
  }
  pre code.hljs {
    padding: 8px;
  }
  code {
    margin-bottom: -60px;
    margin-top: -20px;
    font-size: 12px;
    line-height: 20px;
  }
}
</style>