解决iview在requirejs模式下使用报错:组件未注册

来源:互联网 发布:韩国爱情动作片软件 编辑:程序博客网 时间:2024/04/29 18:47

1、iview在require(AMD)模式下的使用,如下文,已经配置好main.js

requirejs.config({    // baseUrl:'./',    paths:{        jquery:'jquery.min',        less:'less-1.6.3.min',        vue:'vue',        iview:'iview.min',        vueresource:'vue-resource-1.3.4.min'    },    shim:{        vue: {            exports:'Vue'        },        iview: [            'vue'        ],        vueresource: [            'vue'        ]    }})// 注册事件require(['vue', 'iview', 'vueresource'], function(Vue, iview, vueresource) {    Vue.use(iview);    Vue.use(vueresource);});



2、但是在模块中使用的时候,有些组件可以渲染,有些组件就会报错:[Vue warn]: Unknown custom element: <datepicker> - did you register the component correctly? For recursive components, make sure to provide the "name" option. 
(found in <Root>),

搞了半天,原来是命名的问题,组件名须要以中横线分割大哭


错误: <DatePicker type="date" placeholder="选择日期" style="width: 200px" ></DatePicker>


正确:<Date-Picker type="date" placeholder="选择日期" style="width: 200px" ></Date-Picker>

正确效果:


阅读全文
0 0
原创粉丝点击