Skip to content

文件结构

Vue3的文件一般如下

HTML内容

html
<template>

</template>

注意,和Vue2不同,template下面可以有多个标签,不需要唯一的div标签

script内容

html
<script setup lang='ts'>

</script>

注意,如果你需要使用Vue2的语法,见【Vue2】文件结构,可以直接使用,并且两者可以同时存在(不推荐)

style内容

html
<style scoped>

</style>

Vue2相同,添加上scoped可以防止样式穿透

Released under the MIT License.