1要素定義ref属性
2 jsメソッドにより要素のスタイルを修正より多くのスタイルを修正する場合cssText を使用することができる.
function openClose() {
this.isCollapse = !this.isCollapse
if (this.isCollapse) {
this.$refs.btnClick.$el.style.cssText =
'background-color:#1F2429;width:66px';
} else {
this.$refs.btnClick.$el.style.cssText =
'background-color:#1F2429;width:140px';
}
}
3単一のスタイルを変更する場合、スタイル名を直接使用できます.
function openClose() {
this.isCollapse = !this.isCollapse
if (this.isCollapse) {
this.$refs.btnClick.$el.style.color = 'red';
} else {
this.$refs.btnClick.$el.style.color = 'blue';
}
}