vuejs3 - 如何更改 primvue 组件字体系列、字体大小和字体粗细
问题描述
我有 vue3 composition api 和 primevue。我需要更改特定组件的系列、尺寸和重量。我花了一天多的时间,找不到这个信息。具体来说,我需要将下拉菜单更改为字体系列 Lato,字体粗细:粗体,字体大小 1.2vw
我想要一个示例或指出有关如何实现此目的的明确文档。
谢谢您的帮助。
解决方案
您可以覆盖类样式,例如:
.p-dropdown-label,
.p-dropdown-item {
font-family: Lato; // add !important if not applied
font-weight: bold;
font-size: 1.2vw;
}
检查类列表
更新
::v-global(.p-dropdown-label),
::v-global(.p-dropdown-item) {
font-family: Lato !important;
font-weight: bold !important;
font-size: 1.2vw !important;
}
更新 2使用插槽
例子:
<template>
<Dropdown
v-model="selectedCity"
:options="cities"
optionLabel="name"
placeholder="Select a City"
>
<template #value="{ value, placeholder }">
<span class="p-dropdown-label__custom">{{
value ? value.name : placeholder
}}</span>
</template>
<template #option="{ option }">
<span class="p-dropdown-item__custom">{{ option.name }}</span>
</template>
</Dropdown>
</template>
<script>
import Dropdown from "primevue/dropdown/sfc";
export default {
name: "App",
components: {
Dropdown,
},
data() {
return {
selectedCity: null,
cities: [
{ name: "New York", code: "NY" },
{ name: "Rome", code: "RM" },
{ name: "London", code: "LDN" },
{ name: "Istanbul", code: "IST" },
{ name: "Paris", code: "PRS" },
],
};
},
};
</script>
<style lang="scss" scoped>
.p-dropdown-label__custom,
.p-dropdown-item__custom {
font-family: Lato;
font-weight: bold;
font-size: 1.2vw;
}
</style>
推荐阅读
- streaming - PyAudio 输出从自定义源提供的数据处理的信号
- c# - XML 到 DataTable(列表项)
- regex - 递归地用当前IP替换IP
- sql - Redshift:分析数据库中所有表中具有空值的所有列
- ionic2 - 图像缩放 Ionic 2
- c++ - 为什么列表迭代器在 SGI STL 的实现中具有三个模板参数?
- phonegap - phonegap 开发者应用保持下载状态
- javascript - contenteditable 在按键末尾添加多个空格
- c# - 如何在 EntityFramework 中禁用 DynamicProxies
- c++ - Visual Studio 2017 Linux 远程调试(gdbserver)