vue.js适配各个终端_完整的Vue.js终端模拟器

本文介绍了Vue.js终端模拟器,它能完全正常工作,具备使用yargs-parser解析参数、搜索历史、白色/深色主题切换、自动完成等功能。详细阐述了安装步骤、属性和用法。
摘要由CSDN通过智能技术生成

vue.js适配各个终端

Vue命令 (vue-command)

A fully working Vue.js terminal emulator.

完全正常工作的Vue.js终端模拟器。

特征 (Features)

  • Parse arguments with yargs-parser

    使用yargs-parser解析参数

  • Search history (with /)

    搜索记录( / )

  • White/Dark theme support

    白色/深色主题支持

  • Autocomplete (with )

    自动完成(带有 )

安装 (Installation)

$ npm i vue-command --save

物产 (Properties)

PropertyTypeDefaultRequiredDescription
commandsObject{}YesKey-value pairs where key is command and value is function with yargs arguments
help-textStringType helpNoSets the placeholder
help-timeoutNumber4000NoSets the placeholder timeout
hide-barBooleanfalseNoHides the bar
hide-promptBooleanfalseNoHides the prompt
promptString[email protected]:#NoSets the prompt
show-helpBooleanfalseNoShows the placeholder
titleString[email protected]: ~NoSets the title
white-themeBooleanfalseNoEnables the white theme
yargs-optionsObject{}NoSets the yargs options
属性 类型 默认 需要 描述
commands Object {} 键值对,其中key是命令,value是带有yargs参数的函数
help-text String Type help 没有 设置占位符
help-timeout Number 4000 没有 设置占位符超时
hide-bar Boolean false 没有 隐藏酒吧
hide-prompt Boolean false 没有 隐藏提示
prompt String [email protected] :# 没有 设置提示
show-help Boolean false 没有 显示占位符
title String [email protected] : ~ 没有 设置标题
white-theme Boolean false 没有 启用白色主题
yargs-options Object {} 没有 设置yargs选项

用法 (Usage)

<template>
  <vue-command
    :yargs-options="{ alias: { color: ['colour'] } }"
    :commands="commands"
  />
</template>

<script>
import VueCommand from 'vue-command'
import 'vue-command/dist/vue-command.css'

export default {
  components: {
    VueCommand
  },

  data: () => ({
    commands: {
      // yargs arguments
      pokedex: ({ color, _ }) => {
        if (color && _[1] === 'pikachu') return 'yellow'

        return `Usage: pokedex pokemon [option]<br><br>

        Example: pokedex pikachu --color
        `
      }
    }
  })
}
</script>

<style lang="scss">
  .vue-command {
    .term {
      -webkit-border-radius: 8px;
      -moz-border-radius: 8px;
      border-radius: 8px;
    }

    .term-std {
      min-height: 300px;
      max-height: 300px;
      overflow-y: scroll;
    }
  }
</style>

翻译自: https://vuejsexamples.com/a-fully-working-vue-js-terminal-emulator/

vue.js适配各个终端

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值