-2

我已经开始学习 ionic vue。我正在尝试将 css 与离子组件一起使用。所以我在同一个文件中添加了样式

<style scoped>
    .abc {
        background-color: blue;
    }
</style>

并尝试使用

<ion-content class ="abc">
    <ion-header>
        <ion-toolbar>
            <ion-title size="large">My Navigation Bar</ion-title>
        </ion-toolbar>
    </ion-header>
</ion-content>

但它不起作用。我该怎么做呢?这是我的完整代码

<template>
  <ion-page>
    <ion-content class ="abc">
        <ion-header>
          <ion-toolbar>
            <ion-title size="large">My Navigation Bar</ion-title>
          </ion-toolbar>
        </ion-header>
    </ion-content>
  </ion-page>
</template>

<script>
    import { IonContent, IonPage } from "@ionic/vue";
    import { defineComponent } from "vue";

    export default defineComponent({
        name: "Home",
        components: {
            IonContent,
            IonPage
        },
    });
</script>

<style scoped>
    .abc {
        background-color: blue;
    }
</style>
4

1 回答 1

0

我不得不改变代码如下

<style scoped>
    .abc {
        --background: blue;
    }
</style>

并从工具栏中选择 css 类

<ion-toolbar class="abc">
于 2020-11-16T15:57:35.693 回答