vue中component组件化,两个h1,button为什么会显示不了button?单独一个h1、button不采用component就可以实现

pdsu_zhao 2017-09-27 04:46:05
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="app">
<counter></counter>
<counter></counter>
<!--
<button type="button" @click="count +=1">Submit{{ count }}</button>
-->
</div>
<template id="counter-template">
<h1>Hello</h1>
<button type="button" @click="count++">Submit {{ count }}</button>
</template>

<script type="text/javascript" src="js/vue.min.js" ></script>
<script>
Vue.component('counter',{
template:'#counter-template',
data:function(){
count:0
}
});

new Vue({
el:'#app',
});
</script>
</body>
</html>
...全文
191 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

39,087

社区成员

发帖
与我相关
我的任务
社区描述
HTML5是构建Web内容的一种语言描述方式。HTML5是互联网的下一代标准,是构建以及呈现互联网内容的一种语言方式.被认为是互联网的核心技术之一。
社区管理员
  • HTML5社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧