Installation
$ npm i vue-single-file-component-to-js
How to use
$ 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:
$ node index.js /path/to/vue/folder /path/to/js/file.js --watch
Supposing that .vue file is like:
<template> <div> <button class="btn" @click="save">Save</button> </div></template> <script>export default { name: 'MyComponent', data: function(){ return {} }, methods: { save: function(){ alert('save'); } }}</script> <style scoped>.btn {font-size:20px;}</style>
And js file will be:
// ...defination of function docReadyvar MyComponent= template: `<div data-v-32jh24> <button data-v-32jh24 class="btn" @click="save">Save</button> </div>` name: 'MyComponent' { return {} } methods: { ; } ;;
After convert to js file, you can use it in javascript: