当前位置:网站首页>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"]
})
边栏推荐
- Naive Bayes Classification
- See you in shenzhen!Cloud native to accelerate the application building special: see cloud native FinOps, SRE, high-performance computing scenario best practices
- 四、Web开发
- Introduction to Thymeleaf
- error: The following untracked working tree files would be overwritten by
- Unity3D Application simulation enters the front and background and pauses
- 字符串问题(下)
- nSoftware.PowerShell.Server.2020
- Usage of EFR32 as sniffer for Zigbee/Thread
- Simulation Problem (Part 1)
猜你喜欢
![[Awards every week] The](/img/78/4b510b190475d603490614d2c8199f.png)
[Awards every week] The "Edge Containers" track of the Cloud Native Programming Challenge invites you to fight!

Chapter8 支持向量机

Predictive maintenance scheduling of multiple power equipment based on data-driven fault prediction

Some understanding of YOLOv7
![[MRCTF2020]Hello_ misc](/img/ea/0faacf6e544b60e3459d8ace4d5f42.png)
[MRCTF2020]Hello_ misc

Simple experiment with BGP

KubeMeet Registration | The complete agenda of the "Edge Native" Online Technology Salon has been announced!

Excellent MySQL interview questions, 99% must ask in preparation for August!I can't pass the interview

The VUX Datetime component compute-days-function dynamically sets the date list

swagger usage tutorial - quick use of swagger
随机推荐
C. Travelling Salesman and Special Numbers (binary + combination number)
Database Design of Commodity Management System--SQL Server
Repetition XXL - JOB scheduling center background arbitrary command execution
Classification of decision tree classification
LeetCode Algorithm 2326. 螺旋矩阵 IV
Naive Bayes Classification
Unity beginner 5 cameras follow, border control and simple particle control (2 d)
gnss rtcm rtklib Ntrip...
山西省第二届网络安全技能大赛(企业组)部分赛题WP(十)
05 Detailed explanation of the global configuration file application.properties
VUX Datetime 组件compute-days-function动态设置日期列表
Go study notes (84) - Go project directory structure
DAY17、CSRF 漏洞
MySQL operation statement Daquan (detailed)
[Redis Master Cultivation Road] Jedis - the basic use of Jedis
Learning of redis_Basic part
双指针问题(上)
[Android development] Splash interface / user agreement and privacy policy pop-up window / interface development
POJ1321 棋盘问题(详解)
error: The following untracked working tree files would be overwritten by