<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<!-- 这个isshow所在app所在vue中去找 -->
<cpn v-show='isshow'></cpn>
</div>
<template id="cpn">
<div>
<h2>我是子组件</h2>
<p>我是内容,哈哈哈</p>
<!-- 这个isshow所在cpn所在vue中去找 -->
<button v-show="isshow"></button>
</div>
</template>
<script src="../vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
isshow: true
},
components: {
cpn: {
template: '#cpn',
data() {
return {
isshow: false
}
}
}
}
})
</script>
</body>
</html>