Vue實(shí)現(xiàn)固定底部組件的示例
<template> <div id='app'> <div class='main'> <img alt='Vue logo' src='http://m.lshqa.cn/bcjs/assets/logo.png'> <HelloWorld msg='Welcome to Your Vue.js App'/> <img alt='Vue logo' src='http://m.lshqa.cn/bcjs/assets/logo.png'> </div> <div class='footer'>這是固定在底部的按鈕</div> </div></template><script>import HelloWorld from ’./components/HelloWorld.vue’export default { name: ’App’, components: { HelloWorld }}</script><style>:root{ --footer-height: 50px;}body { padding: 0; margin: 0;}#app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px;}.main{ padding-bottom: var(--footer-height); overflow-y: auto;}.footer{ position: fixed; bottom: 0; width: 100%; line-height: var(--footer-height); background: #42b983; color: #fff;}</style>
【增加需求】增加一個(gè)A邏輯,當(dāng)滿足A邏輯的時(shí)候,底部按鈕就不展示,其他情況則展示。新增一個(gè)Bool值(isShow)來(lái)判斷是否顯示底部按鈕,具體代碼如下:
<template> <div id='app'> <div class='main'> <img alt='Vue logo' src='http://m.lshqa.cn/bcjs/assets/logo.png'> <HelloWorld msg='Welcome to Your Vue.js App'/> <img alt='Vue logo' src='http://m.lshqa.cn/bcjs/assets/logo.png'> </div> <div v-if=’isShow’> <div class='footer-content'>這是固定在底部的按鈕</div> </div> </div></template><script>import HelloWorld from ’./components/HelloWorld.vue’export default { name: ’App’, components: { HelloWorld }, data() { return { isShow: true } },}</script><style>:root{ --footer-height: 50px;}body { padding: 0; margin: 0;}#app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px;}.main { overflow-y: auto;}.footer { height: var(--footer-height);}.footer-content { position: fixed; bottom: 0; width: 100%; line-height: var(--footer-height); background: #42b983; color: #fff;}</style>
到此這篇關(guān)于Vue實(shí)現(xiàn)固定底部組件的示例的文章就介紹到這了,更多相關(guān)Vue 固定底部?jī)?nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 將properties文件的配置設(shè)置為整個(gè)Web應(yīng)用的全局變量實(shí)現(xiàn)方法2. html小技巧之td,div標(biāo)簽里內(nèi)容不換行3. nestjs實(shí)現(xiàn)圖形校驗(yàn)和單點(diǎn)登錄的示例代碼4. 以PHP代碼為實(shí)例詳解RabbitMQ消息隊(duì)列中間件的6種模式5. python實(shí)現(xiàn)自動(dòng)化辦公郵件合并功能6. python開(kāi)發(fā)飛機(jī)大戰(zhàn)游戲7. laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)8. css進(jìn)階學(xué)習(xí) 選擇符9. Echarts通過(guò)dataset數(shù)據(jù)集實(shí)現(xiàn)創(chuàng)建單軸散點(diǎn)圖10. Python 如何將integer轉(zhuǎn)化為羅馬數(shù)(3999以內(nèi))
