示例:
<button ref="btn">一个按钮</button>
示例:
mounted() {
this.$refs.btn.style.backgroundColor="red"
}
template 部分:
<template>
<div>
<button ref="btn">一个按钮</button>
</div>
</template>
script 部分:
<script>
export default {
data () {
return {
}
},
mounted () {
this.$refs.btn.style.backgroundColor = 'red'
}
}
</script>