problem description
in the vue project, I want to encapsulate some common functions. I encapsulated the functions, but I moved the functions to a public file and loaded them on demand, prompting me: _ vm.xFunction is not a function
[question]: what is the format in which common functions are defined in vue and support on-demand calls?
related codes
lib/utils.js /
export default {
xFunction (e) {
...
return ...
}
}
//
A.vue
<template>
<div>
<el @click="xFunction(xx)"></el>
</div>
</template>
<script>
import { xFunction } from "@/lib/utils"
</script>
what result do you expect? What is the error message actually seen?
what"s wrong with my writing above? Can the gods give us some advice?