npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mtl-js-sdk

v6.4.8

Published

ynf-fw-mtl-api

Downloads

2,144

Readme

MTL集成文档

mtl-js-sdk.js 是一个轻量的JavaScript库,包含了丰富的API并具有扩展性,解决跨端。

1. 引入方式

  • 本地文件:通过import在项目入口文件处引入 import'文件路径/mtl.(min.)js'
  • cdn地址:通过script标签引入静态资源 <script src="文件路径/mtl.(min.)js">
  • npm:通过npm方式,npm i mtl-js-sdk安装依赖,然后通过 import mtl from "mtl-js-sdk" 的方式引用
// 方式一:本地文件引入方式
// 1. 在 https://npmmirror.com/package/mtl-js-sdk/home 地址获取指定版本的MTL
// 2. 找到 dist/mtl.min.js 将文件放在业务项目指定目录下
// 3. 使用以下方式引入
import mtl from "xx/mtl.min.js"


// 方式二:cdn地址引入
// 正式版地址
<script type="text/javascript" src="https://design.yonyoucloud.com/library/mtl/release/mtl.min.js"></script>
// beta版本地址
<script type="text/javascript" src="https://design.yonyoucloud.com/library/mtl/beta/mtl.min.js"></script>
// 流水线地址(支持私有化)
<script type="text/javascript" src="${domain.url}/library/mtl/beta/mtl.min.js"></script>


// 方式三:npm
> npm i mtl-js-sdk
// 文件中引入
import mtl from "mtl-js-sdk"

mtl 其他版本可在 https://www.npmjs.com/package/mtl-js-sdk?activeTab=versions 查看

注意

  • 在线地址加载的 mtl.js 会在 window 对象上挂 mtl 对象,而本地 import 来的 mtl.js 是根据 from 前定义的名称来决定统一输出的对象,因此在使用时需要注意 mtl 对象的来源。
  • mtl 多版本覆盖逻辑是按照版本号比对后,优先加载版本号最大的,也就是最新的 mtl

2. 调用方式

mtl.(min).js 文件会向全局注入 mtl 对象,所有 mtl 的 api 都注册在 mtl 对象下面。因此通过mtl.apiName的方式进行调用。

例如:

// 扫描二维码
mtl.scanQRCode({
  scanType: ["qrCode", "barCode"],
  needResult: 1,
  success: function(res) {
    var result = res.resultStr;
  },
  fail: function(err) {
    var message = err.message; // 错误信息
  }
});

关于MTL JS的版本:

  1. mtl-js-sdk.js 的新版本默认发布到npm上,然后通过同步逻辑 ynpm 上,开发者通过 npm 或 ynpm 依赖保证版本更新
  2. 可以到mtl-js-package地址,查看版本更新情况,下载 mtl.js 文件以及其他插件js文件