Vue:在使用作用域时,CSS不适用于D3的svg

5

所以这是我的组件代码:

<template>
  <div id="something" class="card">
  </div>
</template>

const height = 200;
const width = 200;

let graph = d3
  .select('#something')
  .append('svg')
    .attr('class', 'chart-container')
    .attr('height', height)
    .attr('width', width);

<style lang="scss" scoped>
.chart-container {
  background-color: aquamarine;
}
</style>

SVG具有应用于.chart-container的类,但没有应用样式。

The image of the inspection tool

然而,当我从<style lang="scss">中移除scoped时,它可以正常工作。

The image of the inspection tool when the code working as intended

为什么它会表现出那种方式?
1个回答

4

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接