Vue warn]: Error compiling template: Templates should only be responsible for mapping the state to

vueJs出现Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as

模板应该只负责将状态映射到ui。避免在模板中放置带有副作用的标记,例如

错误代码

<body>

<div id="app">
<mycom1>
</mycom1>
<script>
 Vue.component('mycom1',{
	template:'<h3>Vue.extend创建的组件</h3>'
}) 
var vm=new Vue({
	el:' #app',		
	})
</script>
</div>
</body>

在这里插入图片描述

原因
原因是你新建VUE实例的代码放在了被绑定的组件
,将’<‘script>标签写到’<'body>’外

发布了58 篇原创文章 · 获赞 20 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_40709110/article/details/100856324