<template>
<div>
<input type="text" ref="input"> // 设置ref属性 通过$refs操作dom
</div>
</template>
<script>
export default {
name: 'ThreeApp',
data() {
return {
};
},
mounted() { // 挂载后可以操作dom
this.$refs.input.style.background = "red" // 通过全局得this.$refs 来操作它得都没属性
},
methods: {
},
};
</script>
<style lang="scss" scoped>
</style>
vue中操作dom
最新推荐文章于 2024-02-07 09:07:54 发布