I’m refactoring code,
I have several functions / methods that are duplicated, I ll create a file with this functions to avoid duplication.
Question , Is this the correct way ?
Example File: helpers/util.js
export const addTitle = ( text ) => {
return 'i added this ' + text
}
export const addText = ( text ) => {
return 'i added this text : ' + text
}
export const email = 'email@teste.com'
My vue component :
<template>
<div class="test-body">
{{ addTitle('I'm an example component') }} , this is my email: {{ email }}
</div>
</template>
<script>
import { addTitle , addText , email } from '@/mixins/test.js';
export default {
data () {
return {
email : email
}
},
methods : {
addTitle , addText ,
},
}
</script>