naive-ui/demo/documentation/components/log/enUS/highlight.demo.md
07akioni 487001d697 build: add changelog to site, refactor loader based on suffix
.demo.md for component demo
.demo-entry.md for demo entry
.md for common docs
2020-08-19 23:30:04 +08:00

999 B

Highlight

Before you use highlight, see Note section of the page to make sure you won't miss messages that are important to make it work.

<n-log
  :log="log"
  @require-top="handlerequireTop"
  @require-bottom="handlerequireBottom"
  :loading="loading"
  language="naive-log"
  trim
/>
function log () {
  const l = []
  for (let i = 0; i < 40; ++i) {
    l.push((Math.random()).toString(16))
  }
  return l.join('\n') + '\n'
}

export default {
  data () {
    return {
      loading: false,
      log: log()
    }
  },
  methods: {
    clear () {
      this.log = ''
    },
    handlerequireTop () {
      if (this.loading) return
      this.loading = true
      setTimeout(() => {
        this.log = log() + this.log
        this.loading = false
      }, 1000)
    },
    handlerequireBottom () {
      if (this.loading) return
      this.loading = true
      setTimeout(() => {
        this.log = this.log + log()
        this.loading = false
      }, 1000)
    }
  }
}