当前位置: 首页 > wzjs >正文

网站排名易下拉技巧给菠菜网站做外包

网站排名易下拉技巧,给菠菜网站做外包,网站底部导航制作,ghost和wordpressTOC 1.思路 通过遍历src/views下的文件,找到.vue文件,截取文件路径的最后两位或全部路径,使用驼峰命名 2.创建脚本 可以通过脚本批量修改 .vue 文件 ‌创建脚本 auto-set-component-name.mjs import fs from "fs" import path…

@TOC

1.思路

通过遍历src/views下的文件,找到.vue文件,截取文件路径的最后两位或全部路径,使用驼峰命名

2.创建脚本

可以通过脚本批量修改 .vue 文件
‌创建脚本 auto-set-component-name.mjs

import fs from "fs"
import path from "path"
import { fileURLToPath } from "url"const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)// 🔧 配置区 ============================================
const targetDir = path.join(__dirname, "src/views")
const PATH_DEPTH = Infinity  // 自由修改数字:2→最后两级,3→最后三级,Infinity→全部路径
// =====================================================const toPascalCase = (str) => {return str.replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/(^\w)/, m => m.toUpperCase()).replace(/\.vue$/, '')
}const processDirectory = (dir) => {const files = fs.readdirSync(dir, { withFileTypes: true })files.forEach(file => {const fullPath = path.join(dir, file.name)file.isDirectory() ? processDirectory(fullPath) : processVueFile(fullPath)})
}const processVueFile = (filePath) => {if (path.extname(filePath) !== '.vue') returnconst relativePath = path.relative(targetDir, filePath)const pathSegments = relativePath.split(path.sep).slice(-PATH_DEPTH) // 🔥 核心修改点:根据配置截取路径段.map(segment => toPascalCase(segment))const componentName = pathSegments.join('')let content = fs.readFileSync(filePath, 'utf8')// 修复正则表达式:支持任意顺序的 setup 属性const scriptSetupRegex = /<script\s+((?:.(?!\/script>))*?\bsetup\b[^>]*)>/gmiif (!content.includes('defineOptions')) {content = content.replace(scriptSetupRegex, (match, attrs) => {return `<script ${attrs}>
defineOptions({name: '${componentName}'
})`})fs.writeFileSync(filePath, content)console.log(`✅ 成功注入 name: ${componentName}${filePath}`)}
}processDirectory(targetDir)
console.log('🎉 所有 Vue 组件 name 注入完成!')

3.‌运行脚本‌

node auto-set-component-name.mjs

文章转载自:

http://ejxrcjKR.xqbbc.cn
http://gHDJaYJa.xqbbc.cn
http://SqPuMJQH.xqbbc.cn
http://lvjEpwRB.xqbbc.cn
http://ijIJcsv3.xqbbc.cn
http://LvMdISfr.xqbbc.cn
http://WG8jru1m.xqbbc.cn
http://7G5RzwRq.xqbbc.cn
http://TLicrojH.xqbbc.cn
http://xnrIGyHC.xqbbc.cn
http://bhUGWTVr.xqbbc.cn
http://QzHPv4i8.xqbbc.cn
http://7F1x41o9.xqbbc.cn
http://sr7CcEEv.xqbbc.cn
http://ofog28vH.xqbbc.cn
http://N8lDi5tZ.xqbbc.cn
http://pFuH5YAr.xqbbc.cn
http://cRQmlvPw.xqbbc.cn
http://Zn9pdF88.xqbbc.cn
http://zhJrai1Q.xqbbc.cn
http://xYFcXjBX.xqbbc.cn
http://zVBzOBf0.xqbbc.cn
http://n2ZKdbyP.xqbbc.cn
http://h2X5oE6X.xqbbc.cn
http://KwWJn5Wq.xqbbc.cn
http://unWhxLZv.xqbbc.cn
http://fxD8x1DL.xqbbc.cn
http://G8YLBkq9.xqbbc.cn
http://NNg9onj2.xqbbc.cn
http://EcFgedo4.xqbbc.cn
http://www.dtcms.com/wzjs/778945.html

相关文章:

  • 房地产手机网站模板聊城网站推广动态
  • 深圳 三人 网站建设阿里云服务器可以做下载类网站吗
  • 东莞 网站建设多少钱网站开发收费表
  • 贵州网站设计公司wordpress发布模块支持5.x
  • 福建省城乡建设信息网站佛山企业网站seo
  • 北京网站开发一般多少钱crm软件有哪些
  • 企业网站建立网站开发软件搭配
  • 怎么制作网站内容蓝色系网站设计
  • 潮州市建设局官方网站wordpress 图书插件
  • 网站正在开发中设计参考网站有哪些
  • 厦门的网站凡科网站模板下载
  • 精美网站设计欣赏建筑书店
  • 做最精彩的绳艺网站上线了建站价格
  • 做网站注意设么商城网站模板免费
  • 东莞网站建设做公司生物商城网站建设
  • 做网站要什么条件wordpress 3.4.2
  • 网站开发 项目介绍网站建设的意义与目的
  • 全椒做网站变更网站怎么做
  • 网站怎么做可以再上面输入文字网站设计深圳公司
  • 长春星宿网站建设公司怎么样广州网站推广联盟
  • 个人网站可以做淘宝客网站吗运营外包
  • 淘宝客一定要建立网站做响应式网站一般都用哪些框架
  • 自考网页制作与网站建设培训学校网站建设要点
  • 重庆有那些制作网站的公司wordpress覆盖密码重置
  • 金华网站如何制作得物app公司怎么样
  • 南城微网站建设太原做响应式网站设计
  • WordPress建立电商网站电子商务网站问题与解决方案
  • 网站开发毕业设计报告学校 网站建设 报销
  • 克隆网站模板网站建设宗旨是指
  • 企业网站的基本功能wordpress 支付