mvc 网站建设长沙新增活动轨迹

张小明 2026/1/7 11:13:59
mvc 网站建设,长沙新增活动轨迹,尼乐清网站建设,中山市西区网站制作一、组件的本质与使用前提在 Vue 中#xff1a;组件 可复用的 UI 行为单元使用组件的前提是#xff1a;先导入#xff08;import#xff09;#xff0c;再注册#xff08;register#xff09;#xff0c;最后使用templateMyComponent / /templat…一、组件的本质与使用前提在 Vue 中组件 可复用的 UI 行为单元使用组件的前提是先导入import再注册register最后使用template MyComponent / /template二、组件的创建基础回顾一个标准 Vue 3 组件SFC!-- components/HelloWorld.vue -- template divHello World/div /template script setup langts /script三、组件注册方式总览重点Vue 3 中常见的组件注册方式有4 种注册方式使用范围是否推荐局部注册当前组件强烈推荐全局注册整个应用谨慎使用script setup自动注册当前组件强烈推荐自动导入插件整个项目企业级推荐四、局部注册最常用、最安全1. Options API传统写法script import HelloWorld from /components/HelloWorld.vue export default { components: { HelloWorld } } /script template HelloWorld / /template特点作用域清晰不污染全局Tree Shaking 友好2. Composition API非 script setupscript import { defineComponent } from vue import HelloWorld from /components/HelloWorld.vue export default defineComponent({ components: { HelloWorld } }) /script五、script setup中的组件注册Vue 3 主流核心结论非常重要在script setup中只要 import就等于注册示例script setup langts import HelloWorld from /components/HelloWorld.vue /script template HelloWorld / /template原理说明简述script setup是编译期语法糖编译器会自动把import的组件注入到模板作用域不再需要components: {}命名规则说明import MyButton from ./MyButton.vue模板中两种写法都可以MyButton / my-button /推荐组件文件名用 PascalCase六、全局组件注册不推荐滥用1. 全局注册方式// main.ts import { createApp } from vue import App from ./App.vue import BaseButton from /components/BaseButton.vue const app createApp(App) app.component(BaseButton, BaseButton) app.mount(#app)使用BaseButton /使用场景合理基础组件Button / Icon / ModalUI 框架封装组件不依赖业务上下文的组件不推荐原因组件来源不清晰不利于 Tree Shaking大型项目中可维护性差七、组件的异步注册性能优化1. 使用defineAsyncComponentscript setup import { defineAsyncComponent } from vue const AsyncComp defineAsyncComponent(() import(/components/HeavyComponent.vue) ) /script template AsyncComp / /template适用场景页面级组件体积大的组件非首屏内容八、自动导入组件企业级方案在 Vue 3 Vite 项目中强烈推荐使用自动导入方案。1. 使用unplugin-vue-componentsnpm install -D unplugin-vue-components2. Vite 配置// vite.config.ts import Components from unplugin-vue-components/vite export default { plugins: [ Components({ dirs: [src/components], extensions: [vue], deep: true }) ] }3. 使用无需 importtemplate HelloWorld / /template优点无需手动 import支持按需加载组件使用体验接近全局组件但更安全九、组件注册常见错误与排查1. 组件未注册Failed to resolve component排查顺序是否import路径是否正确是否大小写不一致是否script setup2. 文件名大小写问题Linux 下常见import helloworld from ./HelloWorld.vue // 错误3. 使用了但未导入template HelloWorld / /template但script setup中没有 import十、最佳实践总结工程经验推荐组件使用策略场景推荐方案业务组件局部注册 / script setup页面组件异步组件基础组件全局或自动导入中大型项目自动导入 局部注册
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网站设计基本要素住房和城乡建设部网站 投诉

save_steps 保存频率设定建议:防止意外中断导致前功尽弃 在使用消费级 GPU 微调 LoRA 模型的日常实践中,你是否经历过这样的场景?深夜启动一个 8 小时的训练任务,满怀期待地准备第二天收获理想模型,结果清晨醒来发现笔…

张小明 2026/1/6 3:49:28 网站建设

网站五合一建设wordpress quform

PyTorch-CUDA-v2.9 镜像:深度学习开发的“标准起点”如何炼成? 在AI研发一线摸爬滚打过的人都懂,一个模型跑不通,八成问题不出在代码逻辑,而是环境——CUDA版本不对、cuDNN缺失、PyTorch和驱动不兼容……这类“在我机…

张小明 2026/1/6 6:27:17 网站建设

销售平台网站建设虹口上海网站建设

5分钟学会Windows 11右键菜单自定义,让你的操作效率翻倍! 【免费下载链接】ContextMenuForWindows11 Add Custom Context Menu For Windows11 项目地址: https://gitcode.com/gh_mirrors/co/ContextMenuForWindows11 还在为Windows 11那简洁但不够…

张小明 2026/1/6 6:27:15 网站建设

常用网站设置微商城网站建设流程方案

Speechless终极指南:一键备份微博的完整解决方案 【免费下载链接】Speechless 把新浪微博的内容,导出成 PDF 文件进行备份的 Chrome Extension。 项目地址: https://gitcode.com/gh_mirrors/sp/Speechless 在数字信息飞速流转的今天,微…

张小明 2026/1/6 6:27:12 网站建设

门户网站建设工作流程四川省和城乡建设厅网站

星露谷农场设计终极指南:用规划器打造你的梦想庄园 【免费下载链接】stardewplanner Stardew Valley farm planner 项目地址: https://gitcode.com/gh_mirrors/st/stardewplanner 你是否曾在星露谷游戏中因为农场布局不合理而浪费宝贵时间?看着别…

张小明 2026/1/6 23:18:38 网站建设

六安品牌网站建设电话网站通栏设计素材

第一章:MCP PowerShell自动化脚本的核心概念 PowerShell 是 Windows 环境下强大的脚本语言与命令行工具,广泛应用于系统管理、配置部署和自动化任务。MCP(Microsoft Certified Professional)认证体系中的 PowerShell 相关技能强调…

张小明 2026/1/6 6:27:08 网站建设