main.js
import Component from '/Component';
require('/file.js');
const app = new Vue({
el: '#app',
components: {
Component
}
});
file.js
sortComputedArray = function(field_name, direction, computedArray){
computedArray.sort() //example instead of lodash.js
}
Component.vue
<template>
<button :click="sortComputedArray('id', 'asc', computedArray)"></button>
</template>
export default {
computed: {
computedArray(){
return this.new_array;
}
},
data(){
return{
new_array: [associativeArrayWithIds]
}
}
}
This is the idea, but I am not sure how to declare that method in the .js file and how to pass the computed property array in order to use this method as a global filter in the future. Any ideas?