Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support definePage() outside of SFC #315

Open
posva opened this issue Feb 15, 2024 Discussed in #314 · 0 comments · May be fixed by #514
Open

Support definePage() outside of SFC #315

posva opened this issue Feb 15, 2024 Discussed in #314 · 0 comments · May be fixed by #514
Labels
⚡️ enhancement improvement over an existing feature

Comments

@posva
Copy link
Owner

posva commented Feb 15, 2024

Contribution welcome!

Discussed in #314

Originally posted by whoooami February 15, 2024
i tried add it inside 1 or 2 position, but doesn't work.

import { defineComponent, ref } from 'vue'
import { useRoute } from 'vue-router'
import { definePage } from 'vue-router/auto'

export default defineComponent({
  setup() {
    // your setup code here

// 1 position.
//definePage({
//  name: 'index',
//  meta: {
//    layout: 'home'
//  }
//})

    const user = useUserStore()
    const name = ref(user.savedName)

    // eslint-disable-next-line unused-imports/no-unused-vars
    const route = useRoute()
    const router = useRouter()
    function go() {
      if (name.value)
        router.push(`/hi/${encodeURIComponent(name.value)}`)
    }

    const { t } = useI18n()
    return () => (
      <>
        <div>
          <div text-4xl>
            <div i-carbon-campsite inline-block />
          </div>
        </div>
      </>
    )
  },
})

// 2 position.
definePage({
  name: 'index',
  meta: {
    layout: 'home'
  }
})
```</div>

---
@settings settings bot removed the enhancement label Feb 21, 2024
@posva posva added the ⚡️ enhancement improvement over an existing feature label Feb 21, 2024
@posva posva linked a pull request Sep 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡️ enhancement improvement over an existing feature
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

1 participant