Vue js Vue-cli 执行“npm run build”,将图像不透明度的 css 编译为 1%

Van*_*anz 8 npm vue.js

当我npm run serve按预期执行所有工作时。

当我执行时npm run build,“没有错误”。

当我在网站上掠夺图像时无法看到图像,然后我检查元素我看到我的画廊部分中的图像不透明度更改为 1%。

在此处输入图片说明

这是我的模板代码:

<div class="gallery container">
  <div
    class="images"
    v-for="(image, index) in images"
    :key="index"
  >
    <img :src="image.small" @click="selectImage(index)" />
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的 scss 代码:

 <style lang="scss" scoped>
    .gallery-wrapper {
      padding: 3rem 0;
      .gallery {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        align-items: center;
        .images {
          display: flex;
          justify-content: center;
          align-items: center;
          img {
            height: auto;
            cursor: pointer;
            width: 100%;
            opacity: 85%;
            border: 5px solid aliceblue;
            &:hover {
              opacity: 100%;
              transition: 0.5s;
              border: none;
              margin: 5px 0;
              box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.62);
              width: 90%;
            }
          }
        }
      }
    }
    </style>
Run Code Online (Sandbox Code Playgroud)

其他图像工作正常。只有画廊图像在执行时会改变不透明度npm run build

我查看了 dist 文件夹,它生成了一个不透明度为 1% 的类。

构建结果 dist/css/app.ae40bac8.css:

 .gallery-wrapper .gallery .images img[data-v-c5a51ec0] {
  height: auto;
  cursor: pointer;
  width: 100%;
  opacity: 1%;
  border: 5px solid #f0f8ff;
}
.gallery-wrapper .gallery .images img[data-v-c5a51ec0]:hover {
  opacity: 1%;
  -webkit-transition: 0.5s;
  transition: 0.5s;
  border: none;
  margin: 5px 0;
  -webkit-box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.62);
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.62);
  width: 90%;
}
Run Code Online (Sandbox Code Playgroud)

似乎 webpack 生成了错误的不透明度。

ura*_*rag 6

对我有用的是使用 0.85 而不是 85%