简体   繁体   English

进行选择时,如何自定义 Quasar 的 QSelect 以粗体显示文本和轮廓

[英]How can I customize Quasar's QSelect to show text and outline in bold, when a selection is made

I'm trying to customize Quasar's QSelect with multiple selection ( https://quasar.dev/vue-components/select#The-display-value ), to show text and outline in bold, when a selection is made.我正在尝试使用多项选择( https://quasar.dev/vue-components/select#The-display-value )自定义 Quasar 的 QSelect,以便在进行选择时以粗体显示文本和轮廓。

I was inspired by this site ( https://www.zalando.dk/herretoej/_beige.gra.sort/ ) and how they use multi select to highlight when a selection is made eg "Farve".我受到这个网站( https://www.zalando.dk/herretoej/_beige.gra.sort/ )的启发,以及他们如何使用多 select 来突出显示何时进行选择,例如“Farve”。

I wanted to do something similar using QSelect and "display-value" from API documentation ( https://quasar.dev/vue-components/select#QSelect-API ).我想使用 API 文档( https://quasar.dev/vue-components/select#QSelect-API )中的 QSelect 和“显示值”来做类似的事情。

My example: https://jsfiddle.net/orbit/351f27ua/30/我的例子: https://jsfiddle.net/orbit/351f27ua/30/

My example: https://jsfiddle.net/orbit/351f27ua/30/

Basically I am trying to make the select have bold text eg "Items (2)" when 2 items has been selected and preferably show a thick border - as shown on ( https://www.zalando.dk/herretoej/_beige.gra.sort/ ) Basically I am trying to make the select have bold text eg "Items (2)" when 2 items has been selected and preferably show a thick border - as shown on ( https://www.zalando.dk/herretoej/_beige.gra .sort/ )

Any idea on how to achieve this using Quasar?关于如何使用 Quasar 实现这一目标的任何想法?

you can customize it using styles and with a conditional class您可以使用 styles 和有条件的 class 对其进行自定义

 new Vue({ el: '#q-app', data: function () { return { version: Quasar.version, itemOptions: ['Item 1', 'Item 2', 'Item 3'], items: [], displayValue: '' } }, methods: { addValue: function (item) { this.items.push(item); this.displayValue = `Items (${this.items.length})`; }, removeValue: function (item) { const index = this.items.findIndex(x => x.value == item.value); this.items.splice(index, 1); this.displayValue = this.items.length?== 0. `Items (${this.items:length})`; ''; } } })
 .custom_selected { border: 2px solid #000000; }.custom_selected.q-field__label, .custom_selected.q-field__native { color: #000000; font-weight: bolder;important; }
 <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@quasar/extras/material-icons/material-icons.css"> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/quasar/dist/quasar.min.css"> <script src="https://cdn.jsdelivr.net/npm/vue"></script> <script src="https://cdn.jsdelivr.net/npm/quasar/dist/quasar.umd.min.js"></script> <div id="q-app" class="q-ma-md"> <div class="q-mb-xl"> Custom QSelect - needs to show bold text when one or more items are selected and a thick border </div> <q-select filled v-model="items" multiple:options="itemOptions":label="items.length < 1? 'Items': undefined":display-value="displayValue" style="width: 150px;" @add="addValue" @remove="removeValue":class="{'custom_selected': items.length>0}"> </q-select> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM