如何給最外層id=app的div添加背景顏色??
我按照老師演示的style綁定,給app添加了背景顏色,但是沒有效果,請問該如何正確設(shè)置其背景色??
代碼如下:
<!DOCTYPE?HTML><html?xmlns:th="http://www.thymeleaf.org"><head> <meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8"?/>????<title>Getting?Started:?Serving?Web?Content</title>????<link?rel="stylesheet"?>????<!--?import?Vue?before?Element?-->?? <script?src="https://unpkg.com/vue/dist/vue.js"></script>?? <!--?import?JavaScript?-->?? <script?src="https://unpkg.com/element-ui/lib/index.js"></script>?? <!--?import?vue-resource?-->??? <script?src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script></head><body>???<!--?hello?wzj?-->??? <div?id="app"?:style="backgroudcolor">??? <!--?獲取檢索信息的表單?-->??? ???</div></body> ?backgroudcolor:?{???????????? backgroundColor:?'red'????????????}
2019-03-06
您好,歡迎關(guān)注,
有多種做法,樓上同學(xué)的方法也是可行的,不過不方便閱讀與修改,建議使用class進(jìn)行樣式的管理。
首先,Class與Style綁定中,Style的綁定要使用駝峰寫法。
如:
:style="backgroundColor: red"
其次,在App.vue組件中,可以對組件加入樣式,寫在<style lang="scss">// 樣式寫在這里</style>
2019-03-05
去掉style前面的冒號(hào)(:),直接賦值即可