Convert .vue file to .js
npm install vue-single-file-component-to-js``sh`
$ npm i vue-single-file-component-to-js
`sh`
$ node index.js /path/to/vue/file.vue /path/to/js/file.js
$ node index.js /path/to/vue/folder /path/to/js/file.js
If you want to convert file when file changed, you can add --watch as the 3rd argument:
`sh`
$ node index.js /path/to/vue/folder /path/to/js/file.js --watch
Supposing that .vue file is like:
`vue
`
And js file will be:
`js
// ...defination of function docReady
var MyComponent={
template:
,
name: 'MyComponent',
data: function(){
return {}
},
methods: {
save: function(){
alert('save');
}
}
};
docReady(function(){
var css = .btn[data-v-32jh24] {font-size:20px;};
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if(style.styleSheet){
style.styleSheet.cssText = css;
}else{
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
});
`After convert to js file, you can use it in javascript:
`html
``