Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://cdn.bootcss.com/vue/2.5.13/vue.min.js"></script>
  <script src="https://cdn.bootcss.com/vuex/3.0.1/vuex.min.js"></script>
  <script src="https://cdn.bootcss.com/vue-router/3.0.1/vue-router.min.js"></script>
</head>
<body>
  <div id="app">
    <p>{{ message }}</p>
    <button @click="xxx = true">打开</button>
    <hr>
    <child :visible="xxx" @close="log"></child>
  </div> 
</body>
</html> 
Vue.component('child', {
  props: ['visible'],
  template: `
    <div>
      我是儿子
      
      <grand-child v-show="visible" @close="$emit('close')"></grand-child>
    </div>
  `
})
Vue.component('grandChild', {
  template: `
    <div>
      我是孙子
      <button @click="$emit('close')">关闭</button>
    </div>
  `
})
new Vue({
  el: '#app',
  data: {
    message: '我是爷爷',
    xxx: false,
  },
  methods: {
    log() {
     "爷爷知道了"
     this.xxx = false
    }
  }
})
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers