javascript - 无法在 vue js 中使用两个组件
问题描述
我是Vue的新手,我有一个问题:
这是我index.html
使用 2 个自定义标签aas和任务:
<!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>)
有办法解决吗?!
解决方案
尝试在您的组件中设置名称:
Vue.component('aas', {
name: 'aas',
template:'<a><slot></slot></a>'
});
根据这个问题,它应该解决该警告。
推荐阅读
- haskell - 如何在 Yesod 持久化中从 Sqllite 中提取值
- mongodb - 无法在我的 ubuntu18.04.02 LTS 上安装 Mongodb
- php - php将json数据发布到api
- flutter - 如何在颤动中制作滚动计数器
- swift - 如何在swift 4中锚定到navigationController
- go - 从已编译的二进制文件中读取命令行标志
- amazon-web-services - AWS Elastic Beanstalk:无法配置自定义日志
- java - Kotlin 数据课与公开课?
- asp.net - 将单独的 ReactJS 客户端前端应用程序与 ASP.NET Core 后端 API 合并?
- android - 如何从 Play 商店中删除应用程序?如果它被删除,它会从已经安装的Mobile中删除吗?