Vue

by zhiyang

HTML

<script src="//unpkg.com/element-ui/lib/index.js"></script>
<div id="app">
 <el-button type="text" @click="open4">点击打开 Message Box</el-button>
</div>

CSS

@import url("//unpkg.com/[email protected]/lib/theme-chalk/index.css");

Vue

Vue.component('custComp',{
  template: '<div>{{a}}<button @click="change">change</button></div>',
  data(){
    return {
      a: 1
    }
  },
  methods: {
    change() {
      this.a = 2
    }
  }
})
var custComp = Vue.component('custComp')
var Main = {
  data() {
    return {
    	key: 1
    }
  },
   methods: {
      open4() {
        const h = this.$createElement;
        // add a unique for VNode
        this.$msgbox({
          title: '消息',
          message: h(custComp, {key: this.key++})
        })
     }
  }
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')