Since the currency filter is deprecated in vue2 I need to import/ use external library accounting.js But I'm facing problem to use accounting.js in my component.
The console show error like this:
[Vue warn]: Property or method "accounting" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in component at C:\project\resources\assets\js\components\ItemProductView.vue)
Here is my app.js
require('./bootstrap');
var accounting = require('./accounting');
module.exports = accounting;
import BannerView from './components/BannerView.vue';
import CategoryView from './components/CategoryView.vue';
import TopProductView from './components/TopProductView.vue';
const app = new Vue({
el: '#app',
data:{
message: 'hello'
},
components:{
BannerView, CategoryView, TopProductView
},
});
and the TopProductView.vue file:
<template>
<div class="row">
<div class="col-sm-6 col-md-3" v-for="item in list">
{{accounting.formatNumber(item.price)}}
<item-product-view :item="item"></item-product-view>
</div>
</div>
</template>
<script>
import ItemProductView from './ItemProductView.vue';
export default {
mounted() {
this.fetchList();
},
components:{
ItemProductView
},
data() {
return {
list: [],
};
},
methods: {
fetchList: function() {
this.$http.post(window.BaseUrl+'/top-product').then(function (response) {
this.list = response.data;
});
},
}
}
</script>
Please help me to find the solution...
Thanks in advance
Hendra1