【发布时间】:2021-08-30 17:57:57
【问题描述】:
我正在尝试在 Vue 中使用 Bootstrap4 为弹出框创建一个组件:
<template>
<div>
<div :id="uid + '_Content'" class="d-none">
<slot name="content">
</slot>
</div>
<div :class="'call' + uid">
<slot name="caller">
</slot>
</div>
</div>
</template>
<script>
module.exports = {
data() {
return {
uid: this.genUID()
}
},
props: {
title: {
type: String,
required: false,
default: ''
}
},
mounted() {
_this = this;
// PopOver Definition
const popover = new bootstrap.Popover(document.querySelector('.call' + this.uid), {
container: 'body',
title: this.title,
html: true,
placement: 'auto',
sanitize: false,
customClass: 'noselect',
content: () => {
return document.querySelector("#" + _this.uid + "_Content").innerHTML;
}
});
},
methods: {
genUID() {
return "Popover_" + Math.random().toString(16).slice(2);
}
}
}
</script>
但是,当从另一个组件向<slot name="content"> 传递内容时,数据不是反应性的。我是否缺少任何配置信息以使其具有反应性?使用 Vue 和(常规)Bootstrap(notBootstrap-Vue)是否可以做到这一点。
【问题讨论】:
标签: vue.js bootstrap-4 vuejs2