class和style绑定

2021-06-29  本文已影响0人  程序媛_

<template> <view> <!-- class --> <view class="static" :class="{ active: isActive}">111</view> <view class="static" :class="{ active: isActive, 'text-danger': hasError }">222</view> <!-- style --> <view v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }">333</view> </view> </template> <script> export default { data() { return { isActive: true, hasError: false, activeColor:"green", fontSize:50 } } } </script> <style> .static{ color: #2C405A; } .active{ background-color: #007AFF; } .text-danger{ color: #DD524D; } </style>

上一篇下一篇

猜你喜欢

热点阅读