常用项目插件

1、前端可以进行复制文字操作的插件   clipboard

npm install clipboard --save

2、 写sql语句高亮的插件 代码编辑器功能 sql语言格式化sql-formatter 搭配使用

vue2-ace-editor         sql-formatter

安装

npm install vue2-ace-editor --save
npm install sql-formatter --save

封装组件

<div class="editor-box">
  <ace
      ref="editor"
      :value="content"
      @init="initEditor"
      :lang="lang"
      :height="height === 0 ? '100%' : height"
      :theme="theme"
      :options="options"
      width="100%"
      v-bind="config">
  </ace>
</div>

<script>
    import ace from 'vue2-ace-editor'
    export default {
        name: 'SqlEditor',
        components: {
            ace
        },
        props: {
            content: {
                type: String,
                default: ''
            },
            height: {
                type: Number,
                default: 0
            },
            readOnly: {
                type: Boolean,
                default: false
            },
            theme: {
                type: String,
                default: 'monokai'
            },
            lang: {
                type: String,
                default: 'sql'
            },
            config: {
                type: Object,
                default: () => {
                    return {
                        font_size: 16,
                        sql_atom: true
                    }
                }
            }
        },
        computed: {
            options () {
                if (this.readOnly) {
                    return {
                        enableBasicAutocompletion: true,
                        enableSnippets: true,
                        enableLiveAutocompletion: this.config.sql_atom,
                        showPrintMargin: false,
                        fontSize: this.config.font_size,
                        readOnly: true
                    }
                }
                return {
                    enableBasicAutocompletion: true,
                    enableSnippets: true,
                    enableLiveAutocompletion: this.config.sql_atom,
                    showPrintMargin: false,
                    fontSize: this.config.font_size
                }
            }
        },
        created () {
        },
        methods: {
            initEditor (editor) {
                require('brace/ext/language_tools')
                // 设置语言
                require('brace/mode/sql')
                require('brace/snippets/sql')
                // 设置主题 按需加载
                require('brace/theme/monokai')
                require('brace/theme/chrome')
                require('brace/theme/crimson_editor')
                // 监听值的变化
                editor.getSession().on('change', val => {
                    this.$emit('change', editor.getValue())
                })
            }
        }
    }
</script>

组件使用

import Editor from '@/components/common/Editor.vue'

<editor
      ref="editors"
      :content="value"
      :theme="'crimson_editor'"
      :config="config"
      @change="editorChange">
</editor>

sql语言格式化sql-formatter

import { format } from 'sql-formatter'

// 方法
formatter () {
    const editor = this.$refs.editor.editor
    const content = editor.getValue()
    const formatContent = format(content)
    editor.setValue(formatContent)
}

3、vue写终端的插件

vue-web-terminal  适用于vue2

npm install vue-web-terminal@2.0.0 --save

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值