[Vuejs]-Write Vue Js component data, methods, props in separate Typescript files

1👍

You should be able to just move the code from the component to each different file and export them as default.

An example for data below:

// data.ts
const data = function() {
   return {
     //data here
   }
}
export default data 

And then use it in the component

export default Vue.extend({
  name: "custom-component",
  data
});

But I would strongly discourage this. You should split your code based on concerns not on structure of the objects. Navigating between all this components for the simplest of tasks will be a great pain.

Leave a comment