39,084
社区成员
发帖
与我相关
我的任务
分享
<template>
<div class="hello">
<h1>
我是父组件
</h1>
<div class="parent" id="parent">
</div>
</div>
</template>
<script>
import Vue from 'vue'
var MyComponent = Vue.extend({
data: function () {
return {
urlId: '',
jsContent: '',
html: `<a @click="show(1)">我是大魔王</a>`
}
},
template: this.html,
methods: {
show (i) {
console.log(i)
}
}
})
var component = new MyComponent().$mount()
export default {
data () {
return {
}
},
methods: {
},
mounted () {
document.getElementById('parent').appendChild(component.$el)
}
}
</script>