I have a function that let's say generates a random string for generating a token. I have this function in my methods:{} and I use it in my div without any problem.
But I am trying to put this function in it's own separate file so I can import it for future use, so I put a functions.js file inside my src like this:
// /src/functions.js
export default {
// generate tokes
tokenGenerator () { ... }
}
And in my src/components/foo.vue I am importing this file (no issues with importing)
<template>
<div> {{ tokenGenerator }} </div>
</template>
<script>
import tokenGenerator from '../../functions'
export default {
data() {
return ;
}
}
</script>
This should work, but it doesn't. Importing is not the issue, but something else.. the console error shows me that It can not find function tokenGenerator