当前位置:网站首页>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"]
})
边栏推荐
- 3. Dependency configuration management
- - B + tree index and MySQL series 】 【 what is the difference between a HASH index
- error: The following untracked working tree files would be overwritten by
- Unity beginner 5 cameras follow, border control and simple particle control (2 d)
- 字符串问题(上)
- 聊一聊什么是SaaS,以及遇到的问题......
- 【软件工程之美 - 专栏笔记】31 | 软件测试要为产品质量负责吗?
- Predictive maintenance scheduling of multiple power equipment based on data-driven fault prediction
- labelme的使用技巧
- POJ1321 棋盘问题(详解)
猜你喜欢

The Complete Go Books - Beginner to Advanced and Web Development

Stimulsoft ReportsJS and DashboardsJS. 2022.3.3

GCC Rust is approved to be included in the mainline code base, or will meet you in GCC 13

共建共享数字世界的根:阿里云打造全面的云原生开源生态

【 notes 】 the beauty of the software engineering - column 31 | software testing are responsible for the quality of products?

The Azure developer news 丨 memorabilia in July

Chapter8 Support Vector Machines

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

VUX Datetime 组件compute-days-function动态设置日期列表

Introduction to Thymeleaf
随机推荐
Mini Program wx.miniProgram.navigateTo jump address cannot be tabbar address
- B + tree index and MySQL series 】 【 what is the difference between a HASH index
双指针问题(上)
MYSQL unique constraint
(Problem practice) Conditional probability + weight line segment tree + FWT + suffix array
labelme的使用技巧
SVN 查看用户名密码
MySQL operation statement Daquan (detailed)
Small programs use npm packages to customize global styles
Protobuf compound data types, speaking, reading and writing
Machine Learning: Knowing the Dimensionality Reduction Process Through Low Variance Filtering
字符串问题(上)
Shi Xingguo, founder of Hyperchain, was interviewed by 21st Century Business Herald to interpret Shanghai's new NFT regulations and digital development
Some understanding of YOLOv7
The 2nd Shanxi Province Network Security Skills Competition (Enterprise Group) Partial WP (10)
Code readability, pre-checks, comments and summaries
5. View parsing and template engine
DAY17:弱口令的探测与测试
Simulation Problem (Part 1)
How to use labelme