vue-json-viewer icon indicating copy to clipboard operation
vue-json-viewer copied to clipboard

内容为字符串时复制问题

Open BayMax619 opened this issue 1 year ago • 0 comments
trafficstars

  const clipBoard = new Clipboard(this.$refs.clip, {
    container: this.$refs.viewer,
    text: () => {
      return JSON.stringify(this.value, null, 2)
    }
  });

value如果是字符串不需要JSON.stringify

  const clipBoard = new Clipboard(this.$refs.clip, {
    container: this.$refs.viewer,
    text: () => {
      if (typeof this.value === 'string') {
        return this.value;
      }
      return JSON.stringify(this.value, null, 2)
    }
  });

BayMax619 avatar Jun 21 '24 09:06 BayMax619