admin管理员组

文章数量:1278758

Hi everyone im new to Vue JS and im trying to use mixins on my filters using single file template and I'm having some hard time

Error I'm getting

Unknown custom element: <side-bar-one> - did you register the ponent correctly? For recursive ponents, make sure to provide the "name" option. 

ponent.js

Vueponent('sideBarOne', require('./ponent/sidebars/sideBarOne.vue'));

sideBarOne.vue

import { default as config } from '../../../config';
import { filters as filter } from '../../../mixins/filters';

export default {
        mixins: [
            filter,
        ],
        mounted: function() {
        }
 }

filters.js

import { default as config } from '../config';
module.exports = {
    filters: {
        useLGLogo( str ) {
            if( str ) {
                return config.LG_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
            }
        },
        useMDLogo( str ) {
            if( str ) {
                return config.MD_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
            }
        },
        useSMLogo( str ) {
            if( str ) {
                return config.SM_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
            }
        },
    }
};

Hi everyone im new to Vue JS and im trying to use mixins on my filters using single file template and I'm having some hard time

Error I'm getting

Unknown custom element: <side-bar-one> - did you register the ponent correctly? For recursive ponents, make sure to provide the "name" option. 

ponent.js

Vue.ponent('sideBarOne', require('./ponent/sidebars/sideBarOne.vue'));

sideBarOne.vue

import { default as config } from '../../../config';
import { filters as filter } from '../../../mixins/filters';

export default {
        mixins: [
            filter,
        ],
        mounted: function() {
        }
 }

filters.js

import { default as config } from '../config';
module.exports = {
    filters: {
        useLGLogo( str ) {
            if( str ) {
                return config.LG_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
            }
        },
        useMDLogo( str ) {
            if( str ) {
                return config.MD_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
            }
        },
        useSMLogo( str ) {
            if( str ) {
                return config.SM_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
            }
        },
    }
};
Share Improve this question asked May 8, 2017 at 7:12 PenAndPapersPenAndPapers 2,1089 gold badges34 silver badges64 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

I've made some changes on my files and made it working

filters.js

    import { default as config } from '../config';
    var filters = {
        filters: {
            useLGLogo( str ) {
                if( str ) {
                    return config.LG_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
                }
            },
            useMDLogo( str ) {
                if( str ) {
                    return config.MD_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
                }
            },
            useSMLogo( str ) {
                if( str ) {
                    return config.SM_LOGO + str.replace(/\s+/g, '-').toUpperCase() + '.png';
                }
            },
        }
    };

export default filters;

sideBarOne.vue

import { default as filters } from '../../../mixins/filters';
    export default {
        mixins: [
            filters,
        ],
        mounted: function() {
        }
    }

本文标签: javascriptVue Js how to use in mixins in single file templateStack Overflow