2
大家好进出口新的Vue的JS和IM试图使用单个文件模板我的过滤器使用的混入,我有一些很难Vue Js如何在单个文件模板中使用mixin?
错误我得到
Unknown custom element: <side-bar-one> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
component.js
Vue.component('sideBarOne', require('./component/sidebars/sideBarOne.vue'));
sideBarOne.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';
}
},
}
};
可以导入默认出口只有一个名字。 '从'导入过滤器,而不是'import {default as filters}' –