Semver 语义化版本 JavaScript 实现

Semver JavaScript About 1,240 words

安装依赖

npm install semver

使用

<template>
  <div>
    <p>
      1.2.3 valid1: {{ valid1 }}
    </p>
    <p>
      a.b.c valid: {{ valid2 }}, valid2 === null?: {{ valid2 === null }}, valid2 === undefined?:
      {{ valid2 === undefined }}
    </p>
    <p>
      1.2.3 > 9.8.7: {{ gt }}
    </p>
    <p>
      1.2.3 < 9.8.7: {{ lt }}
    </p>
    <p>
      sort: {{ sort }}
    </p>
    <p>
      major: {{ major }}, minor: {{ minor }}, patch: {{ patch }}
    </p>
    <p>
      min version: {{ minVersion }}
    </p>

  </div>
</template>

<script>
import semver from "semver";

export default {
  name: "LearnSemVerComponent",
  data() {
    return {
      valid1: semver.valid('1.2.3'),
      valid2: semver.valid('a.b.c'),
      gt: semver.gt('1.2.3', '9.8.7'),
      lt: semver.lt('1.2.3', '9.8.7'),
      sort: semver.sort(['1.2.3', '1.2.1', '1.2.4']),
      major: semver.major("1.2.3"),
      minor: semver.minor("1.2.3"),
      patch: semver.patch("1.2.3"),
      minVersion: semver.minVersion('>1.0.0')
    }
  }
}
</script>

依赖地址

https://www.npmjs.com/package/semver

开源地址

https://github.com/npm/node-semver

Views: 969 · Posted: 2023-03-28

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh