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

Categories

我在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”后缀?求大佬解答。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.1k views
Welcome To Ask or Share your Answers For Others

1 Answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...