feat: enable ref sugar by default & remove annoying warnings (#319)

This commit is contained in:
Cuvii 2022-03-23 22:48:07 +08:00 committed by GitHub
parent d0f6274ac4
commit d4e831355e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{
"cSpell.words": ["Vitesse"],
"cSpell.words": ["Vitesse", "Vite", "unocss", "vitest", "vueuse", "pinia", "demi", "antfu", "iconify", "intlify", "vitejs", "unplugin", "pnpm"],
"i18n-ally.sourceLanguage": "en",
"i18n-ally.keystyle": "nested",
"i18n-ally.localesPaths": "locales",

View File

@ -45,6 +45,8 @@ Mocking up web app with <b>Vitesse</b><sup><em>(speed)</em></sup><br>
- 🔥 Use the [new `<script setup>` syntax](https://github.com/vuejs/rfcs/pull/227)
- 🤙🏻 [Reactivity Transform](https://vuejs.org/guide/extras/reactivity-transform.html) enabled
- 📥 [APIs auto importing](https://github.com/antfu/unplugin-auto-import) - use Composition API and others directly
- 🖨 Static-site generation (SSG) via [vite-ssg](https://github.com/antfu/vite-ssg)

View File

@ -45,6 +45,8 @@
- 🔥 使用 [新的 `<script setup>` 语法](https://github.com/vuejs/rfcs/pull/227)
- 🤙🏻 默认开启 [响应性语法糖](https://vuejs.org/guide/extras/reactivity-transform.html)
- 📥 [API 自动加载](https://github.com/antfu/unplugin-auto-import) - 直接使用 Composition API 无需引入
- 🖨 使用 [vite-ssg](https://github.com/antfu/vite-ssg) 进行服务端生成 (SSG)

View File

@ -1,6 +1,13 @@
// Generated by 'unplugin-auto-import'
// We suggest you to commit this file into source control
declare global {
const $: typeof import('vue/macros')['$']
const $$: typeof import('vue/macros')['$$']
const $computed: typeof import('vue/macros')['$computed']
const $customRef: typeof import('vue/macros')['$customRef']
const $ref: typeof import('vue/macros')['$ref']
const $shallowRef: typeof import('vue/macros')['$shallowRef']
const $toRef: typeof import('vue/macros')['$toRef']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
const computed: typeof import('vue')['computed']

View File

@ -2,12 +2,12 @@
import { useUserStore } from '~/stores/user'
const user = useUserStore()
const name = ref(user.savedName)
const name = $ref(user.savedName)
const router = useRouter()
const go = () => {
if (name.value)
router.push(`/hi/${encodeURIComponent(name.value)}`)
if (name)
router.push(`/hi/${encodeURIComponent(name)}`)
}
const { t } = useI18n()

View File

@ -15,6 +15,7 @@
"forceConsistentCasingInFileNames": true,
"types": [
"vite/client",
"vue/ref-macros",
"vite-plugin-pages/client",
"vite-plugin-vue-layouts/client"
],

View File

@ -25,6 +25,7 @@ export default defineConfig({
plugins: [
Vue({
include: [/\.vue$/, /\.md$/],
reactivityTransform: true,
}),
// https://github.com/hannoeru/vite-plugin-pages
@ -41,6 +42,7 @@ export default defineConfig({
'vue',
'vue-router',
'vue-i18n',
'vue/macros',
'@vueuse/head',
'@vueuse/core',
],