1. 安裝lodash
npm i lodash --save
2. 全局使用 main.ts
.......
import _ from 'lodash'
const app = createApp(App)
app.config.globalProperties.lodash = _; // 設置全局變了
3. 界面使用
......
import { getCurrentInstance } from "vue"
const { proxy } = getCurrentInstance()
// 生成隨機數
console.log(proxy.lodash.random(0,10))
4. 按需引入使用
// 按需引入,並設置別名
import { round as _round } from 'lodash'
......
console.log(_round(9.1234, 2) // 四捨五入,保留兩位小數。
5. lodash中文文檔路徑
https://www.lodashjs.com/