我试图建立非常简单的引导警报组件,但我无法弄清楚如何获得我的自定义组件的innerHTML
。
代码:
Vue.component('my-alert', {
template: '#vue-alert',
props: ['type', 'title', 'message'],
created: function() {
this.message = this.innerHTML; // <---- NOT WORKING
}
});
var vm = new Vue({
el: 'body'
});
HTML:
<my-alert type="success" title="Important">My Message here.</my-alert>
我希望显示组件中提供的任何文本,在本例中,它应该显示My Message here.
https://stackoverflow.com/questions/39056039
复制相似问题