注意js中的变量要带上单位
vue3
const height = ref(0);
const top = ref(0);
height.value = wx.getMenuButtonBoundingClientRect().height + 'px';
top.value = wx.getMenuButtonBoundingClientRect().top + 'px';
position: absolute;
height: v-bind(height);
top: v-bind(top);
vue2
data(){
return {
width:'200px',
color:'#f00',
margin:'10px 20px 10px 20px',
}
}
.test{
width: var(--width);
color: var(--color);
margin: var(--margin);
}