<template>
<div class="example">
<h1>Hello Vue with SCSS</h1>
<p>This is a paragraph styled with SCSS.</p>
</div>
</template>
<script>
export default {
name: 'ScssExample'
}
</script>
<style lang="scss">
.example {
h1 {
color: #42b983;
font-size: 2em;
}
p {
color: #666;
font-size: 1.2em;
}
}
</style>
Template部分:
<h1>
标题和一个<p>
段落。Script部分:
ScssExample
的组件。Style部分:
<style lang="scss">
标签来引入SCSS语法。.example
类选择器用于包裹整个组件的内容。h1
和p
的选择器被嵌套在.example
内,表示这些样式只应用于.example
下的h1
和p
元素。这样,你就可以在Vue项目中使用SCSS来编写更简洁、更易维护的样式代码。
上一篇:npm 安装vue
下一篇:vue3 router.push
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站