Recently in the development of multi-terminal development, encountered a magical pit, that is to write on the components of the style does not take effect, torturing for a long time, finally the curve to save the country. Let’s talk about the problems and solutions.
Problem: Writing styles directly on components does not work in applets.
<view class="ServiceNoteTitle W100">Class ="closerButton" this direct control is not effective, published to the H5 page is effective, but published to the small program is invalid<uni-icon @click="closerButton" class="closerButton" :type="'closeempty'" :size="50"></uni-icon>
</view>
<style scoped>
.closerButton {
display: inline-block;
position: absolute;
right: 10upx;
}
</style>
Copy the code
The solution
<view class="ServiceNoteTitle W100">Service description<view class="closerButton">
<uni-icon @click="closerButton" :type="'closeempty'" :size="50"></uni-icon>
</view>
</view>
<style scoped>
.closerButton {
display: inline-block;
position: absolute;
right: 10upx;
}
</style>
Copy the code
conclusion
On this magical pit toss about for a long time, fortunately solved, recorded, convenient for their future development, and can also help you. Multi terminal development pit is indeed many, many trips pit. Progress is made.