【发布时间】:2018-08-02 06:38:30
【问题描述】:
所以我想使用指令绑定样式,因为我需要测试发送到元素的值。
<div v-portrait="photo.portrait"></div>
问题是我需要访问我的组件的data(),但我不知道怎么做,因为this 超出了范围。
directives: {
portrait: {
bind: function (el, binding) {
if(binding.value == true){
console.log(this); //undefined
el.height = (this.rowHeight)+ 'px';
}
}
}
}
那么我如何检索this.rowHeight?
【问题讨论】:
标签: vue.js