- css中使用
>>>
- scss中使用
::v-deep
1. css
<template>
<div class="a" v-html="content"></div>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
let content = ref( 'this is a <a class="b">Test</a>')
}
return {
content
}
}
}
</script>
<style scoped>
.a >>> .b {
color: red;
}
</style>
2. scss
<template>
<div class="a" v-html="content"></div>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
let content = ref( 'this is a <a class="b">Test</a>')
}
return {
content
}
}
}
</script>
<style lang="scss" scoped>
.a ::v-deep .b {
color: red;
}
</style>