1. highlight-vue
[`prismjs`](https://prismjs.com/) for vue component.
highlight-vue
Package: highlight-vue
Created by: yujinpan
Last modified: Fri, 09 Sep 2022 08:55:01 GMT
Version: 1.1.6
License: MIT
Downloads: 158
Repository: https://github.com/yujinpan/highlight-vue

Install

npm install highlight-vue
yarn add highlight-vue

highlight-vue

prismjs for vue component.

https://yujinpan.github.io/highlight-vue/

Usage

Install

npm install --save highlight-vue

Global

 import Vue from 'vue';
import Highlight from 'highlight-vue';

// theme(required)
// light style
import 'highlight-vue/lib/themes/light';
// dart style
// import 'highlight-vue/lib/themes/dart';

Vue.use(Highlight);
<Highlight :code="code" lang="xml" />

Local

<template>
  <Highlight class="code" :code="code" lang="xml" />
</template>

<script>
import Highlight from 'highlight-vue';

// theme(required)
// light style
import 'highlight-vue/lib/themes/light';
// dart style
// import 'highlight-vue/lib/themes/dart';

export default {
  components: {
    Highlight
  },
  data() {
    return {
      code: '<Highlight :code="code" lang="xml" />'
    };
  }
};
</script>

Add language pack

 import 'prismjs';
import 'prismjs/components/prism-java';
<Highlight :code="javaCode" lang="java" />

More themes

 import 'prismjs/themes/prism-dark.css';

Props

  • code the code content
  • lang the language, default import js, css, scss, shell, xml
  • pre add the <pre></prev tag to wrap, default true

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin