Can i use multiple Vue Composable functions in one file? how do I structure it?

Advertisements

Can i use multiple vue composables in one file?
example:

<script>
export function arrayToInt(arr) {
...
}

export function arrayToUint(arr) {
...
}
</script>

then somewhere else:

import {arrayToInt, arrayToUint} from "./useBytesHelper"

because im getting a vue router parsing error right at the beggining when loading my app. and i might be doing this wrong

>Solution :

Considering that the file is JavaScript module (useBytesHelper.js) and not Vue SFC (useBytesHelper.vue), it’s incorrect to use <script> tag there.

The rest is correct, it should be used as listed:

import {arrayToInt, arrayToUint} from "./useBytesHelper"

Leave a ReplyCancel reply