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
Table of contents Select Structure Loop Structure...
1. Introduction to Navicat 1. What is Navicat? Na...
It is common to view code effects in different br...
Table of contents Preface 【undo log】 【redo log】 【...
vue-element-admin import component encapsulation ...
Table of contents Math Objects Common properties ...
Table of contents 1. Demand 2. Solution 3. The fi...
npm uninstall sudo npm uninstall npm -g If you en...
Recently, a system was deployed, using nginx as a...
The semantics, writing style, and best practices ...
There are two solutions: One is CSS, using backgro...
When the token expires, refresh the page. If the ...
Execute the command to install the plugin postcss...
As shown below: select name from mysql.proc where...
MySQL database basic syntax DDL Operations Create...