vue自定義封裝按鈕組件
更新時間:2021年09月23日 11:29:44 作者:run-Ameng
這篇文章主要為大家詳細(xì)介紹了vue自定義封裝按鈕組件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
vue按鈕組件的自定義封裝代碼,供大家參考,具體內(nèi)容如下
封裝按鈕組件 button.vue
<template> <button class="button ellipsis" :class="[size,type]"> <slot /> </button> </template> <script> export default { name: 'Button', props: { size: { type: String, default: 'middle' }, type: { type: String, default: 'default' } } } </script> <style scoped lang="less"> .button { appearance: none; border: none; outline: none; background: #fff; text-align: center; border: 1px solid transparent; border-radius: 4px; cursor: pointer; } .large { width: 240px; height: 50px; font-size: 16px; } .middle { width: 180px; height: 50px; font-size: 16px; } .small { width: 100px; height: 32px; font-size: 14px; } .mini { width: 60px; height: 32px; font-size: 14px; } .default { border-color: #e4e4e4; color: #666; } .primary { border-color: #27BA9B;; background: #27BA9B;; color: #fff; } .plain { border-color:#27BA9B;; color:#27BA9B;; background: lighten(#27BA9B;,50%); } .gray { border-color: #ccc; background: #ccc;; color: #fff; } </style>
封裝組件的使用
<Button type="primary" style="margin-top:20px;">自定義按鈕名字</Button> <Button type="primary" style="margin-top:20px;">加入購物車</Button>
實(shí)現(xiàn)效果
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
相關(guān)文章
axios+vue請求時攜帶cookie的方法實(shí)例
做項(xiàng)目時遇到一個需求,后端需要在接口請求時,對用戶登陸狀態(tài)進(jìn)行判斷,需要在請求時攜帶Cookie,下面這篇文章主要給大家介紹了關(guān)于axios+vue請求時攜帶cookie的相關(guān)資料,需要的朋友可以參考下2022-09-09vue3+element?Plus使用el-tabs標(biāo)簽頁解決頁面刷新不回到默認(rèn)頁的問題
這篇文章主要介紹了vue3+element?Plus使用el-tabs標(biāo)簽頁頁面刷新不回到默認(rèn)頁的操作方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-07-07ruoyi-vue3 集成aj-captcha實(shí)現(xiàn)滑塊、文字點(diǎn)選驗(yàn)證碼功能
這篇文章主要介紹了 ruoyi-vue3 集成aj-captcha實(shí)現(xiàn)滑塊、文字點(diǎn)選驗(yàn)證碼,本文基于后端RuoYi-Vue 3.8.7 和 前端 RuoYi-Vue3 3.8.7,集成以AJ-Captcha文字點(diǎn)選驗(yàn)證碼為例,不需要鍵盤手動輸入,極大優(yōu)化了傳統(tǒng)驗(yàn)證碼用戶體驗(yàn)不佳的問題,感興趣的朋友一起看看吧2023-12-12