I added a set of functions into
Vue.prototype.elantana = require("./shared/elantana.js").default;
at my main.js; since I need this functions all alone my app.
Accessing to this set of functions is a piece of cake. I pass the 'this' object as a param to acces the vue object
<div v-if="elantana.CheckPermission(this, 'fabrics@add_fabric')">
<b-button class="float-button" variant="warning" @click="ShowEditModal">+</b-button>
</div>
Problem comes when running this same function into a b-table component template:
<b-table class="table-outline bg-white" :hover="true" :striped="false" :bordered="false" :small="false" :fixed="false" responsive="sm" :items="fabrics" :fields="tableFields" :current-page="currentPage" :per-page="perPage" head-variant="light">
<template slot="actions" slot-scope="data">
<div class="float-right">
<div v-if="elantana.CheckPermission(this, 'fabrics@edit_fabric')">
<b-button class="mr-2" type="button" size="sm" variant="danger" @click="ShowEditModal(data.item)"><i class="fa fa-trash-o"></i></b-button>
</div>
</div>
</template>
</b-table>
[Vue warn]: Error in render: "TypeError: Cannot read property '$store' of null"
This is the prototype of the function
/**
* Returs if the permissions is in the avaialable permissions array
* @param {VUE object} vm
* @param {String} permission
* @return {Boolean}
*/
CheckPermission(vm, permission)
I thought in overpass the issue with a method inside the component acting as a proxy for the main function, or creating a prop in the component that returns the "this" object
Any way to use the "this" object inside bootstrap b-table template?
return this.elantana.CheckPermission(this, 'fabrics@edit_fabric')
and use it inside the templatev-if="myComputedProperty"
– Sovalina