Vue 支持

Nasti 内置 Vue 3 单文件组件(SFC)支持。

安装

Vue 的 SFC 编译器作为可选依赖,需要手动安装:

npm install vue
npm install -D @vue/compiler-sfc

特性

配置

// nasti.config.ts
import { defineConfig } from 'nasti-build'

export default defineConfig({
  framework: 'vue',
})

示例

入口文件

// src/main.ts
import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')

组件

<!-- src/App.vue -->
<script setup lang="ts">
import { ref } from 'vue'

const count = ref(0)
</script>

<template>
  <div>
    <h1>Nasti + Vue</h1>
    <button @click="count++">Count: {{ count }}</button>
  </div>
</template>

<style scoped>
h1 { color: #42b883; }
</style>

HMR 行为

注意: 如果没有安装 @vue/compiler-sfc, Nasti 会在控制台输出警告并跳过 .vue 文件的编译。