当前位置:网站首页>[Nuxt 3] (十一) 传送 & 模块
[Nuxt 3] (十一) 传送 & 模块
2022-07-25 14:31:00 【choukin】
“你这里的人,在一座花园里就种了五千株玫瑰花,却没能从中找到自己想找的东西。” ———— 《小王子》
传送
Vue 3 内置了 <Teleport> 组件 允许组件内容渲染到Vue 外部的任何DOM上.
<teleport> 的 to 属性,接收一个CSS 选择器,或者一个真实的DOM节点。Nuxt 目前SSR部分支持吃 传送到 body,客户端要使用 <ClientOnly> 包裹后支持渲染到其他目标上。
示例: body teleport
<template>
<button @click="open = true">
Open Modal
</button>
<Teleport to="body">
<div v-if="open" class="modal">
<p>Hello from the modal!</p>
<button @click="open = false">
Close
</button>
</div>
</Teleport>
</template>
示例: client-side teleport
<ClientOnly>
<Teleport to="#some-selector">
<!-- content -->
</Teleport>
</ClientOnly>
</template>
模块
Nuxt 提供了一个模块系统来扩展框架核心以及简化集成方式。对于已经存在的模块,你需要要重新开发或维护脚手架,你可以在nuxt.config中添加你要使用的模块。
探索 Nuxt 模块
当使用Nuxt 开发生产级应用时,你可能会发现框架的核心功能还不够。Nuxt 可以通过配置选项和插件进行扩展,但在多个项目中维护这些配置会很繁琐,且重复。另一方面,开箱即用地支持每个项目的需求会让Nuxt 变得非常复杂难用。
这是Nuxt提供一个模块系统来扩展核心功能的一个原因。Nuxt 模块是异步函数,在执行nuxi dev 或 nuxi build时它们会顺序执行。它们可以替换模版,配置webpackde loaders ,添加CSS库,以及执行许多其他有用的任务。
最棒的是,Nuxt 模块可以通过npm包来管理,这使得它们可以跨项目重用并与社区共享,有助于创建一个高质量的附加组件生态系统。
扩展阅读[1]
modules 属性
安装模块后,你可以把它们添加到 nuxt.config.ts 文件中的 modules 属性中。模块的开发者通常会提供额外的操作步骤和使用细节。
export default defineNuxtConfig({
modules: [
// Using package name (recommended usage)
'@nuxtjs/example',
// Load a local module
'./modules/example',
// Add module with inline-options
['./modules/example', { token: '123' }]
// Inline module definition
async (inlineOptions, nuxt) => { }
]
})
Nuxt 模块现在只在构建时可用,Nuxt2中buildModules属性被modules替换了。
模块的开发
每个人都可以开发模块,在模块开发指引中阅读更多开发模块的知识。
参考资料
Nuxt 3 Compatible Modules: https://modules.nuxtjs.org/?version=3.x"
边栏推荐
- The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path
- 国联证券买股票开户安全吗?
- Resource not found: rgbd_launch 解决方案
- Vs2017 large factory ERP management system source code factory general ERP source code
- Paddlenlp之UIE关系抽取模型【高管关系抽取为例】
- Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]
- Initial flask and simple application
- Two Sum
- English语法_不定代词 - other / another
- DVWA practice - brute force cracking
猜你喜欢

Wechat official account official environment online deployment, third-party public platform access

51单片机学习笔记(1)

~4.2 CCF 2021-12-1 sequence query
![Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]](/img/b6/62a346174bfa63fe352f9ef7596bfc.png)
Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]

基于浏览器的分屏阅读

如何设计一个高并发系统?

maya建模练习

【MySQL必知必会】触发器 | 权限管理

Teach you how to apply for SSL certificate

Doris学习笔记之与其他系统集成
随机推荐
gson与fastjson
Filters get the data in data; Filters use data in data
~5 new solution of CCF 2021-12-2 sequence query
Melodic + Realsense D435i 配置及错误问题解决
Two Sum
From fish eye to look around to multi task King bombing -- a review of Valeo's classic articles on visual depth estimation (from fisheyedistancenet to omnidet) (Part I)
【MySQL必知必会】触发器 | 权限管理
如何让一套代码完美适配各种屏幕?
filters获取data中的数据;filters使用data中的数据
Gameframework making games (I)
优质数对的数目[位运算特点+抽象能力考察+分组快速统计]
关于ROS2安装connext RMW的进度条卡在13%问题的解决办法
Gameframework making games (II) making UI interface
QObject源码剖析-d指针和q指针
sudo rosdep init Error ROS安装问题解决方案
Cologne new energy IPO was terminated: the advanced manufacturing and Zhanxin fund to be raised is the shareholder
疫情之下,生物医药行业或将迎来突破性发展
Why do China Construction and China Railway need this certificate? What is the reason?
IDEA设置提交SVN时忽略文件配置
Products on Apple's official website can save 600 yuan by buying iPhone 13 Pro max at a discount