用于 Nuxt 的 Lodash
💡 关于
📦 安装
- 安装
nuxt-lodash
作为开发依赖
npm i nuxt-lodash -D
- 将其添加到你的
nuxt.config
的modules
部分
export default defineNuxtConfig({
modules: ["nuxt-lodash"],
});
🚀 示例
在你的 Nuxt 应用程序中使用任何 Lodash 方法,它们将被自动导入!
<script setup>
const text = useToUpper("it works!");
</script>
<template>
<div>{{ text }}</div>
</template>
🔨 配置
名称 | 默认 | 描述 |
---|---|---|
前缀 | 'use' | 在每个 Lodash 函数前添加的字符串 (false 禁用) |
前缀跳过 | 'is' | 以这些关键字开头的函数将被前缀跳过 (false 禁用) |
前缀后大写 | true | 如果为 true,它将自动将前缀后的第一个字母大写 (false 禁用) |
排除 | [] | 从自动导入中排除的 Lodash 函数数组 |
别名 | [] | 用于重命名特定 Lodash 函数的数组对数组 (仍然添加前缀) |
💻 示例 - 配置
export default defineNuxtConfig({
modules: ["nuxt-lodash"],
lodash: {
prefix: "_",
prefixSkip: ["string"],
upperAfterPrefix: false,
exclude: ["map"],
alias: [
["camelCase", "stringToCamelCase"], // => stringToCamelCase
["kebabCase", "stringToKebab"], // => stringToKebab
["isDate", "isLodashDate"], // => _isLodashDate
],
},
});
📄 许可证
MIT 许可证 © 2021-2022 - Michal Čípa