当前位置:网站首页>Nuxt3 learning
Nuxt3 learning
2022-07-30 04:46:00 【Han.】
1 路由
配置pages文件,nuxtThe mapping relationship of the path is automatically created
动态路由
//配置文件名为XXX-[参数].vue的形式
<NuxtLink to="/user-24"> //这个24is the passed parameter
//Passing multiple parameters requires configuring nested routes
<NuxtLink to="/user-xie/user-24">
嵌套页面
同级创建parent和parent.vue,在parent文件夹中创建child.vue
在parent.vue中使用NuxtChildIntroduce sub-routing pages
插槽
在layoutto any file in the slot,Requires component configuration to act as a slotNuxtLayout,并带上name
//Match multiple slots,文件名为default.vue
<slot name="one"></slot>
<slot name="two"></slot>
<NuxtLayout name="default">
<template #one></template>
<template #two></template>
<NuxtLayout>
Put the public functions that need to be calledcomposables文件夹下,This way you don't need to import it when you call it
Nuxt3请求数据的方法
(1)useAsyncData
const res=await useAsyncData('getList',()=>$fetch(url),{
Lazy:true})
const list=res.data._rawValue.data
(2)useFetch
const res=await useFetch(url,{
method:'get',id:1})
路由中间件
When jumping from one page to another,The code executed during the jump process
//建立middleware文件夹,在文件夹下新建default.global.ts文件
export default defineNuxtRouteMiddle((to,from)=>{
abortNavigation()//give up access
navigateTo() //Visit another page
})
//If the middleware only works on a single component,Configure as follows in the component
definePageMeta({
middleware:["default"]
})
边栏推荐
- Machine Learning: Knowing the Dimensionality Reduction Process Through Low Variance Filtering
- 共建共享数字世界的根:阿里云打造全面的云原生开源生态
- labelme的使用技巧
- A brief introduction to the SSM framework
- mysql隔离级别
- file system two
- GCC Rust is approved to be included in the mainline code base, or will meet you in GCC 13
- Discourse 自定义头部链接(Custom Header Links)
- Whole process scheduling - Azkaban entry and advanced
- How to use labelme
猜你喜欢
cnpm installation steps
mysql隔离级别
【 notes 】 the beauty of the software engineering - column 31 | software testing are responsible for the quality of products?
webService interface
Perspective transformation matrix of image perspective correction should be matrix (single)/findHomography with getPerspectiveTransformd difference
【线性表】- LeetCode力扣三道练习题详解
Protobuf compound data types, speaking, reading and writing
5. View parsing and template engine
Building and sharing the root of the digital world: Alibaba Cloud builds a comprehensive cloud-native open source ecosystem
DAY17:弱口令的探测与测试
随机推荐
Classification of decision tree classification
Golang eight-legged text finishing (continuous handling)
字符串问题(下)
POJ1321 chessboard problem (detailed explanation)
Code readability, pre-checks, comments and summaries
模拟问题(上)
DAY17、CSRF 漏洞
Detailed explanation of REUSE_ALV_GRID_DISPLAY
Weight line segment tree + line segment tree split/merge + CF1659D
swagger usage tutorial - quick use of swagger
See you in shenzhen!Cloud native to accelerate the application building special: see cloud native FinOps, SRE, high-performance computing scenario best practices
Excellent MySQL interview questions, 99% must ask in preparation for August!I can't pass the interview
Become a qualified cybersecurity, do you know this?
How to use labelme
The 2nd Shanxi Province Network Security Skills Competition (Enterprise Group) Part of the WP (9)
Chapter8 支持向量机
山西省第二届网络安全技能大赛(企业组)部分赛题WP(九)
The Double Pointer Problem (Part 2)
Get the local IP and Request's IP
file system two