vue generate component
1.0.0
CLI Util for Easy Gere Vue JS Component
npm install - g vue - generate - component vgc --helpvgc footerIrá gerar cinco arquivos:
Footer.js
export default {
name : 'footer' ,
props : [ ] ,
mounted ( ) { } ,
data ( ) {
return { } ;
} ,
methods : { } ,
computed : { }
} ;Footer.spec.js
import Vue from 'vue' ;
import FooterComponent from './index.vue' ;
// Here are some Jasmine 2.0 tests, though you can
// use any test runner / assertion library combo you prefer
describe ( 'FooterComponent' , ( ) => {
// Inspect the raw component options
it ( 'has a created hook' , ( ) => {
// expect(typeof FooterComponent.created).toBe('function');
} ) ;
// Evaluate the results of functions in
// the raw component options
it ( 'sets the correct default data' , ( ) => {
// expect(typeof FooterComponent.data).toBe('function')
// const defaultData = FooterComponent.data();
// expect(defaultData.message).toBe('hello!');
} ) ;
// Inspect the component instance on mount
it ( 'correctly sets the message when created' , ( ) => {
// const vm = new Vue(FooterComponent).$mount();
// expect(vm.message).toBe('bye!');
} ) ;
// Mount an instance and inspect the render output
it ( 'renders the correct message' , ( ) => {
// const Ctor = Vue.extend(FooterComponent);
// const vm = new Ctor().$mount();
// expect(vm.$el.textContent).toBe('bye!');
} ) ;
} ) ;Footer.html
< section class =" footer " >
< h1 > footer Component </ h1 >
</ section >Footer.scss
. footer {
}index.vue
< template src =" ./footer.component.html " > </ template >
< script src =" ./footer.component.js " > </ script >
< style src =" ./footer.component.scss " scoped lang =" scss " > </ style >vgc -s homeirá gerar um arquivo VUE:
< template lang = "html" >
< section class = "home" >
< h1 > home Component </ h1 >
</ section >
</ template >
< script lang = "js" >
export default {
name : 'home' ,
props : [ ] ,
mounted ( ) {
} ,
data ( ) {
return {
}
} ,
methods : {
} ,
computed : {
}
}
< / script>
< style scoped lang = "scss" >
.home {
}
</ style >vgc -s home --foldervgc -d my-directiveirá gerar:
My-Directive.Direction.js
import Vue from 'vue' ;
Vue . directive ( 'my-directive' , {
bind ( ) { } ,
// When the bound element is inserted into the DOM...
inserted ( el ) {
// el.focus();
} ,
update ( ) { } ,
unbind ( ) { }
} ) ;vgc footer --postfix pageIrá gerar arquivos com Postfix:
sudo vgc --html jade --style less --script ts --spec tsSe você deseja consertar/melhorar os modelos, é bem -vindo a criar um PR.