2
이 + 부트 스트랩-VUE 뷰 2 의 첫 단계이며, 나는 전혀 있도록 동적으로 속성의 이름을 변경하는 방법을 알아 내려고 노력하고있어 작은 화면 해상도는 툴팁의 위치를 변경합니다.뷰 2 + 부트 스트랩-VUE - 동적 속성
JS 코드는 아래 잘 작동하지만 툴팁 ( 은 내 실수 개선 도와주세요 = 자신의 위치를 변경하지;
.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);
}
});
});
브라우저 - 크롬
브라우저 콘솔 - 크롬
v-b-tooltip은 지시어이며 구성 요소가 아닙니다. OP가 지시어에 동적 수정자를 추가하려고합니다. – Bert
@Bert Ah, 고마워. 내 대답을 업데이트 할게. – Franey