【问题标题】:Ionic5 vue3 can't add background image to <ion-content>Ionic 5 vue 3 无法将背景图片添加到 <ion-content>
【发布时间】:2022-01-09 12:13:45
【问题描述】:

嗨,黑客和帅哥:
关注这篇文章Ionic full screen background image。我猜是vue特有的bug。

代码:

background_image_sample.vue

<template>
  <ion-page>
    <ion-content>
      <h1>background_image_sample Page2</h1>
    </ion-content>
  </ion-page>
</template>

<script>
import { IonPage, IonContent } from "@ionic/vue";
import './background_image_sample.css';

export default {
  components: {
    IonPage,
    IonContent,
  },
};
</script>

background_image_sample.css

ion-content {
  --background: url('./assets/background.png') 0 0/100% 100% no-repeat
}

云环境:codesandbox

【问题讨论】:

    标签: css image vue.js ionic-framework


    【解决方案1】:

    您应该将其导入script 标签而不是 放在样式标签上

    &lt;style src="./background_image_sample.css"&gt;&lt;/style&gt;

    <style lang="scss" scoped>
     @import "./background_image_sample.css";
    </style>
    

    我不太确定@import 可能仅适用于sass/scss 语言

    【讨论】:

    • 首先感谢mr.403 welling的帮助。不幸的是,我仔细检查确保导入 css 是成功的。如果你有时间。邀请您访问代码沙箱。你看到当前的环境。我在那里报告了问题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-10-28
    • 2020-08-05
    • 1970-01-01
    • 2017-05-10
    • 2020-02-06
    • 2021-03-17
    • 1970-01-01
    • 2018-04-28
    相关资源
    最近更新 更多