大家好,我是Vue JS的新手,我正在try 使用单文件模板在我的过滤器上使用mixin,我遇到了一些困难

我犯了个错误

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

组成部分js

Vue.component('sideBarOne', require('./component/sidebars/男爵.vue'));

男爵.vue

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

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

过滤器.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';
            }
        },
    }
};

推荐答案

我对我的文件做了一些更改,使其正常工作

过滤器.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;

男爵.vue

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

Vue.js相关问答推荐

Vue3组合-如何在组件卸载时注销回调

可组合数据获取示例

有没有办法将react 键作为值传递给由 v-for 创建的 v-model

vue3 输入标签给出错误 Vue.use 不是函数

如何在 vue2.7 中删除 slot-scope

Vue 脚本标签中更漂亮的 destruct 功能

如何将 vuejs 项目部署到 heroku

在 Vue 项目之间共享assets和组件

有条件地在 Vue 中添加一个 CSS 类

如何创建 vuetify 工具栏链接下拉菜单?

等待来自 WDS 的更新信号

Vuetify - 如何在 v-data-table 中单击时突出显示行

Vuetify 2 个工具栏和 1 个导航抽屉,navigation drawer导航抽屉上方有 1 个工具栏

Jest错误找不到模块....

使用 Vue-cli,我在哪里声明我的全局变量?

为 Vue 组件动态添加属性

即使在生产模式下构建,VueJS 也会显示开发模式开发模式消息

嵌套组件

使用 vuejs 动态设置 id 标签

v-bind:class 的 Vue.js 计算(computed)属性