Extend vue script setup syntax,make it support the name and inheritAttrs attribute.
MIT License
English | 简体中文
Extend vue script setup syntax,make it support the name and inheritAttrs attribute.
npm
npm i unplugin-vue-setup-attributes -D
Config plugin in build tool configuration file,such as vite.config.ts,vue.config.js and webpack.config.js
Vite
// vite.config.ts
import { Plugin, defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueSetupAttributes from 'unplugin-vue-setup-attributes'
export default defineConfig({
plugins: [vue(), vueSetupAttributes()],
})
Webpack
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-vue-setup-attributes')()
]
},
}
// webpack.config.js
module.exports = {
plugins: [
require('unplugin-vue-setup-attributes')()
]
}
<script setup lang="ts" name="Home" inheritAttrs="false">
import { ref } from 'vue'
const foo = ref("foo")
</script>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'Home',
inheritAttrs: false,
})
</script>
<script setup lang="ts">
import { ref } from 'vue'
const foo = ref("foo")
</script>
MIT License © 2022 zedyuan999