QingWei-Li / vuep

🎡 A component for rendering Vue components with live editor and preview.
https://cinwell.com/vuep/
MIT License
886 stars 103 forks source link
component editor playground preview vue vue-components

Vuep (vue playground)

Build Status Coverage Status npm

🎡 A component for rendering Vue components with live editor and preview.

image

Links

Installation

Yarn

yarn add vuep codemirror
# npm i vuep codemirror -S

HTML tag

<!-- Import theme -->
<link rel="stylesheet" href="https://github.com/QingWei-Li/vuep/blob/master//unpkg.com/vuep/dist/vuep.css">

<!-- depend vue -->
<script src="https://github.com/QingWei-Li/vuep/raw/master//unpkg.com/vue"></script>
<script src="https://github.com/QingWei-Li/vuep/raw/master//unpkg.com/vuep"></script>

Quick start

Need the full (compiler-included) build of Vue

webpack config

{
  alias: {
    'vue$': 'vue/dist/vue.common'
  }
}
import Vue from 'vue'
import Vuep from 'vuep'
import 'vuep/dist/vuep.css'

Vue.use(Vuep /*, { codemirror options } */)
// or Vue.component('Vuep', Vuep)

new Vue({
  el: '#app',

  created: function () {
    this.code = `
      <template>
        <div>Hello, {{ name }}!</div>
      </template>

      <script>
        module.exports = {
          data: function () {
            return { name: 'Vue' }
          }
        }
      </script>
    `
  }
})

Usage A

<div id="app">
  <vuep :template="code"></vuep>
</div>

Usage B

you can write in HTML file or even a markdown file.

<div id="app">
  <vuep template="#example"></vuep>
</div>

<script v-pre type="text/x-template" id="example">
  <template>
    <div>Hello, {{ name }}!</div>
  </template>

  <script>
    module.exports = {
      data: function () {
        return { name: 'Vue' }
      }
    }
  </script>
</script>

Scope

You can customize scope by passing an object to the scope property.

This object can contain component available in main scope to include them into Vuep.

import Features from 'features' // Import component

new Vue({ el: '#app', data: function () { return { scope: { Features }, // Set the scope of vuep value: `

Githubissues.
  • Githubissues is a development platform for aggregating issues.