ceci est mes premiers pas dans Vue 2 + bootstrap vue, et je suis en train de comprendre comment changer dynamiquement le nom d'un attribut, de sorte que, à une petite résolution d'écran l'info-bulle change de position.Vue 2 + Bootstrap-vue - attribut dynamique
JS code ci-dessous fonctionne très bien, mais infobulle ne change pas sa position = ( S'il vous plaît me aider à améliorer mon erreur,
.pug
JS
'use strict';
import Vue from 'vue';
import BootstrapVue from 'bootstrap-vue';
document.addEventListener("DOMContentLoaded", function() {
Vue.use(BootstrapVue);
new Vue({
el: '#freshbroccoli',
data: {
windowWidth: null,
position: this.windowWidth >= 480 ? 'left' : 'bottom'
},
mounted() {
this.$nextTick(function() {
window.addEventListener('resize', this.getWindowWidth);
this.getWindowWidth();
});
},
methods: {
getWindowWidth() {
this.windowWidth = document.documentElement.clientWidth;
console.log('this.windowWidth >= 480 ? \'left\' : \'bottom\'', this.windowWidth >= 480 ? 'left' : 'bottom', '\n', this.windowWidth);
}
},
beforeDestroy() {
window.removeEventListener('resize', this.getWindowWidth);
}
});
});
navigateur - Chrome
console navigateur - Chrome
v-b-tooltip est une directive, pas un composant. OP tente d'ajouter un modificateur dynamique à une directive. – Bert
@Bert Ah, merci. Je vais mettre à jour ma réponse. – Franey