Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

vue3使用render函数后,css样式失效,求解?

我在vue3中使用了render函数,如下

<script>
import {h} from 'vue';
export default {
  name: "test1",
  render() {
    return h('div', {class: 'color'}, 'test')
  }
}
</script>
<style scoped>
.color {
  color: red;
}
</style>

然后发现样式未生效,然后在浏览器端发现实际生成的样式为

<style type="text/css">
.color[data-v-6d5fa6bc] {
  color: red;
}
</style>

生成的dom为

<div class="color" data-v-6d5fa6bc-s="" data-v-52b17e8b="">test</div>

多了“-s”导致css不生效,但为什么会多了这个“-s”后缀?求大佬解答。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...