我是Vue的新手,我有一个问题:
这是我的index.html
,我使用了2个自定义标记aas、和index.html
:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="root">
<aas></aas>
<task></task>
</div>
<script src="../index/vue.js"></script>
<script src="main.js"></script>
</body>
</html>
和我的main.js
:
Vue.component('aas', {
template:'<a><slot></slot></a>'
});
Vue.component('task', {
template:'<li><slot></slot></li>'
});
new Vue({
el:'#root'
});
但我有一个错误:
vue.js:597 [Vue warn]: Unknown custom element: <aas> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)
有没有办法解决它?!
发布于 2018-05-29 08:51:29
尝试在组件中将名称设置为:
Vue.component('aas', {
name: 'aas',
template:'<a><slot></slot></a>'
});
根据this issue的说法,它应该解决这个警告。
https://stackoverflow.com/questions/50572892
复制相似问题