本篇文章為大家展示了v-bind指令如何在VUE中使用,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),羅定企業(yè)網(wǎng)站建設(shè),羅定品牌網(wǎng)站建設(shè),網(wǎng)站定制,羅定網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,羅定網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
1. v-bind:class(根據(jù)需求進(jìn)行選擇)
1.1
<style> .box{ background-color: #ff0; } .textColor{ color: #000; } .textSize{ font-size: 30px; } </style> <div id="app"> <span class="box" :class="{'textColor':isColor, 'textSize':isSize}">我是字</span> </div> <script> new Vue({ el: "#app", data:{ isColor:true, isSize:true } }) </script>
1.2
<style> .box{ background-color: #ff0; } .textColor{ color: #000; } .textSize{ font-size: 30px; } </style> <div id="app"> <span class="box" :class="classObject">我是字</span> </div> <script> new Vue({ el: "#app", data:{ classObject:{ 'textColor': true, 'textSize': true } } }) </script>
1.3
<style> .box{ background-color: #ff0; } .textColor{ color: #0f0; } .textSize{ font-size: 30px; } </style> <div id="app"> <span class="box" :class="[classA,classB]">我是字</span> </div> <script> new Vue({ el: "#app", data:{ classA: 'textColor', classB: 'textSize' } }) </script>
1.4
<style> .box{ background-color: #ff0; } .textColor{ color: #0f0; } .textSize{ font-size: 30px; } </style> <div id="app"> <span class="box" :class="[isA?classA:'', classB]">我是字</span> </div> <script> new Vue({ el: "#app", data:{ classA: 'textColor', classB: 'textSize', isA: false } }) </script>
2.v-bind:style (根據(jù)需求進(jìn)行選擇,駝峰式)
2.1
<div id="app"> <span class="box" :>我是字</span> </div> <script> new Vue({ el: "#app", data:{ activeColor: 'red', size: '30px', shadow: '5px 2px 6px #000' } }) </script>
2.2
<div id="app"> <span class="box" :>我是字</span> </div> <script> new Vue({ el: "#app", data:{ styleObject:{ color: 'red', fontSize: '30px', textShadow: '5px 2px 6px #000' } } }) </script>
2.3
<div id="app"> <span class="box" :>我是字</span> </div> <script> new Vue({ el: "#app", data:{ styleA:{ fontSize: '30px', color: 'red' }, styleB:{ textShadow: '5px 2px 6px #000' } } }) </script>
2.4
<div id="app"> <span class="box" :>我是字</span> </div> <script> new Vue({ el: "#app", data:{ styleA:{ fontSize: '30px', color: 'red' }, styleB:{ textShadow: '5px 2px 6px #000' }, isA: false } }) </script>
3.v-bind:src
<div id="app"> <img :src="url" /> </div> <script> new Vue({ el: "#app", data:{ url: "../img/pg.png" } }) </script>
4.v-bind:title
<div id="app"> <div :title="message">我是字</div> </div> <script type="text/javascript"> new Vue({ el: "#app", data:{ message:"我是吱吱" } }) </script>
上述內(nèi)容就是v-bind指令如何在VUE中使用,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
本文名稱:v-bind指令如何在VUE中使用
網(wǎng)頁(yè)鏈接:http://chinadenli.net/article14/gohcde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、域名注冊(cè)、商城網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)