uniapp dynamically modifies the style, use style to dynamically modify the style, and avoid pitfalls

uniapp dynamically modifies the style, use style to dynamically modify the style, and avoid pitfalls

Use echarts to make a histogram nested in <view>. After inverting the xy axis, it will not automatically expand <view>. So I plan to modify the chart height based on the calculated number of data items.
In the WeChat applet.

After querying, it is found and placed in the form of an object style. The code is as follows:

<view class="uChart" :style="echartClass">
data(){
	return{
		echartClass: {
			height: "85upx"
		}
	}
}

I don't know why it doesn't work. Upx changes the car to px and rpx also doesn't work.

Find a way below to write the object directly styleinto

<view :style="{height: echartsHeight +'rpx'}">
data() {
	return {
		echartsHeight :80
	}
}

Here I am writing a WeChat applet. According to the uniapp writing method, upx should be used, but writing upx here is invalid, so the corresponding pixel unit should be used according to the platform. WeChat mini program uses rpx, which can also be used with px.

If you have a better solution, I hope you can leave a message and learn from each other.

Guess you like

Origin blog.csdn.net/weixin_44223509/article/details/126390792