标签: accounting.js

Vuejs 2使用accounting.js

由于货币过滤器在vue2中已弃用,我需要导入/使用外部库accounting.js但是我在组件中使用accounting.js时遇到问题.

控制台显示如下错误:

[Vue警告]:属性或方法"accounting"未在实例上定义,但在呈现期间引用.确保在数据选项中声明反应数据属性.(在C:\ project\resources\assets\js\components\ItemProductView.vue中的组件中找到)

这是我的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
    },

});
Run Code Online (Sandbox Code Playgroud)

TopProductView.vue文件:

    <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 { …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js accounting.js laravel-5.3

1
推荐指数
1
解决办法
2577
查看次数

标签 统计

accounting.js ×1

javascript ×1

laravel-5.3 ×1

vue.js ×1