1. 程式人生 > >Vue對於dom的操作

Vue對於dom的操作

efs refs 方法 div sub 只需要 this pre 標簽

Vue中有時候我們還是需要直接操作DOM的,,只需要在標簽上加上$refs就可以直接操作

<button ref="test">test</button>

操作:

this.$refs.test.innerHTML = "test"           //js操作;操作元素的方法
this.$refs.sub.$el = "test" //js操作;操作組件的方法

Vue對於dom的操作