1. Modify by binding the style attribute The first step: you must get the element node There is no windou object in the uniApp project, so the dom node cannot be directly obtained through the document. The refs of vue are only valid for custom components and not for tags in uniapp. Check the uniapp official website for a uni.createSelectorQuery() API; you can use this property to get the style of the label and then modify it by dynamically binding the style; html:<button type="default" @click="handleFont">Click to increase font</button> <view class="weibo_box" id='index0' :style="{fontSize:vHeight + 'px'}"> Corresponding js:data(){ return { vHeight:22 } }, handleFont(){ const that=this uni.createSelectorQuery().select('#index0').boundingClientRect(function (data) { console.log('element information 0:', data) that.vHeight +=10 }).exec() } The effect achieved: Second, use ref to get the DOM element nodeCode:<button type="default" @click="handleFont">Click to increase font</button> <view class="weibo_box" id='index1' ref="mydom"> The second one data(){ return { vHeight:22 } }, //Some codes are irrelevant, omit handleFont(){ const that=this that.$refs.mydom.$el.style.fontSize=that.vHeight+=1+'px' } The effect achieved: SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: How to quickly copy large files under Linux
>>: Summary of knowledge points related to null (IFNULL, COALESCE and NULLIF) in MySQL
The establishment of MySQL index is very importan...
System environment: Redis version: 6.0.8 Docker v...
The first step is to install TypeScript globally ...
1. Introduction Whether the creation time of a fi...
Install MySQL under Windows for your reference. T...
This effect is most common on our browser page. L...
I searched a lot online and found that many of th...
We often want to find a file in Linux, but we don...
Table of contents Overview 1. Overview of input a...
I have been working on a project recently - Budou...
1. Overview The image in Docker is designed in la...
Preface Recently, I have been busy dealing with s...
Angular Cookie read and write operations, the cod...
The CSS3 category menu effects are as follows: HT...
Table of contents Preface 1. Routing lazy loading...