Giter Site home page Giter Site logo

dannyfeliz / require-vuejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edgardleal/require-vuejs

1.0 3.0 0.0 395 KB

RequireJS plugin to async and dynamic load and parse .vue components

Home Page: https://edgardleal.github.io/require-vuejs/

License: MIT License

JavaScript 100.00%

require-vuejs's Introduction

require-vuejs

RequireJS plugin to async and dynamic load and parse .vue single file components

Build Status codecov Code Climate

This library has only 4Kb ( minified ).

What this library can do

  • Real time integration
  • Don't need build to use
  • Used as RequireJS plugin
  • You can use syntax detection from your IDE
  • Suport for single file component
  • Work with or without extencion
  • Support .html and .vue files
  • CSS inside component file

What this library can't do

  • Parse Jade and other templates
  • Scoped css

CDN

Developent ( last version )

https://rawgit.com/edgardleal/require-vuejs/master/dist/require-vuejs.js

For production usage: ( Fast CDN, long age cache and minified )

https://cdn.rawgit.com/edgardleal/require-vuejs/aeaff6db/dist/require-vuejs.min.js

Instalation from NPM repository

npm install require-vuejs

Usage

This example on Codepen

File structure

app.js
component.vue
index.html

Source code example

index.html

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8" />
        <title>Require Vue</title>
    </head>
    <body>
        <div id="app">
            <my-component></my-component>
    </div>
        <script data-main="app" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js" ></script>
    </body>
</html>

Create your component: ( component.vue )

<template>
  <div>
      {{text}}
  </div>

</template>

<script>
  define(["Vue"], function(Vue) {
      Vue.component("my-component", {
          template: template, // the variable template will be injected 
          data: function() {
              return {"text": "Ok"};
          }
      });
    });
</script>

Create your app code: ( app.js )

requirejs.config({
    paths: {
        "Vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.1/vue.min",
        "vue": "https://rawgit.com/edgardleal/require-vue/master/dist/require-vuejs"
    },
    shim: {
        "Vue": {"exports": "Vue"}
    }
});

// to use component in your code with RequireJS: 
// put a reference to your component file with or without extencion after 'vue!' 
require(["Vue", "vue!component"], function(Vue){
    var app = new Vue({
        el: "#app"
    });
});

Licence

MIT

Code of Conduct

https://js.foundation/conduct/

require-vuejs's People

Contributors

edgardleal avatar

Stargazers

Karina Rodriguez Herrera avatar

Watchers

James Cloos avatar Danny Feliz avatar  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.