Giter Club home page Giter Club logo

vue-code-view's Introduction

Vue Code View(VCV)

Build Status GitHub license npm npm bundle size npm

English | ็ฎ€ไฝ“ไธญๆ–‡

A lightweight code interaction component based on vue 2.x, which can edit, run and preview the code effect display in real time on the web page.

When reading docs that contain a lot of code, many project docs implement a render representation of the sample code via the markdown loader, but it is static. When we want to debug code, we generally need to open the local IDE or open online editor websites such as codepen, codesandbox, and it is also subject to whether the computer has a development environment installed or whether the network connection is smooth.

So can there be such a component that can support editing code in the page, edit, run and preview the code effect display in real time in the web page?

Special thanks to the component react-code-view, based on which the vue version of the component was written! Using this component, you can edit the running code and preview the effect in real time by using the multi-sample code in the vue page or the markdown document.

โšก Online Demo

็คบไพ‹

demo address: https://andurils.github.io/vue-code-view/#/demo

codesandbox example: vue-code-view-example

โœจ Features

  • ๐Ÿ’ป Code can be edited online and preview the effect in real time.
  • ๐ŸŽจ Support sample code highlighting, configure themes.
  • ๐ŸŒˆ Support <style> parsing and rendering.
  • ๐Ÿ“‘ Support Markdown file example rendering

๐Ÿ“ฆ Install

npm i vue-code-view
# or
yarn add vue-code-view

๐Ÿ”จ Configure

Using vue cli requires configuration in the vue.config.js file, which supports the use of Vue builds that include the runtime compiler.

module.exports = {
  runtimeCompiler: true,
  // or
  chainWebpack: (config) => { 
    config.resolve.alias
      .set("vue$", "vue/dist/vue.esm.js");
  },
}; 

๐Ÿ’ป Usage

Components are introduced in the entry file main.js, and there is no need to manually introduce styles.

import Vue from "vue";
import App from "./App.vue";
import CodeView from "vue-code-view";

Vue.use(CodeView);

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");

๐Ÿ“š API

Props

Property Description Type Default Version
themeMode code editor theme mode,default light `` | dark ``
showCode show the code editor , only layout value is top takes effect boolean false
source source code string -
layout render view layout top | right | left top 0.4.0+

๐Ÿ“‹ Changelog

Detailed changes for each release are documented in the release notes.

๐Ÿ’ก Inspired

Inspired by shared links.

๐Ÿ’ณ License

VCV is licensed under the terms of the MIT License.

Copyright (c) 2021-present Anduril

vue-code-view's People

Contributors

andurils avatar xch1029 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.