此页内容

代码复制

pengzhanbo

204字小于1分钟

2024-03-06

概述

主题内置的代码复制插件,在代码块中插入复制按钮。

关联插件: @vuepress-plume/plugin-copy-code

默认配置:

import { plumeTheme } from 'vuepress-theme-plume'
import { defineUserConfig } from 'vuepress'

export default defineUserConfig({
  theme: plumeTheme({
    plugins: {
      copyCode: {
        selector: '.page-content div[class*="language-"] pre',
      },
    }
  }),
})






 
 
 



配置

selector

  • 类型: string
  • 默认值: '.page-content div[class*="language-"] pre'

用于指定复制按钮应用的代码块选择器。

duration

  • 类型: number
  • 默认值: 1500

用于置顶 提示消息显示时间。 设置为 0 将会禁用提示。

showInMobile

  • 类型: boolean
  • 默认值: false

用于控制是否在移动端显示复制按钮。

禁用

你可以指定 copyCode: false 来禁用插件。

import { plumeTheme } from 'vuepress-theme-plume'
import { defineUserConfig } from 'vuepress'

export default defineUserConfig({
  theme: plumeTheme({
    plugins: {
      copyCode: false,
    }
  }),
})