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 🙏

© 2024 – Pkg Stats / Ryan Hefner

m2-vue

v1.2.0

Published

The package is provided facilities and utilities based on vue.

Downloads

11

Readme

m2-vue

M2基于Vue框架封装的应用框架库。

用法

  • 安装
npm install m2-vue

APIs

  • render 渲染Vue应用的根组件。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | rootApp | object | 当前应用的根组件(可能是对象或组件) | — | — | | options | object | 当前扩展配置 | — | {router,store,env,i18n,plugins,fastclick,cookie,lazy,init} |

import { render } from 'm2-vue'
// 全量加载
// import M2 from 'm2-ui'
// import Element from 'element-ui'
// 按需加载
import plugins from './plugins'
import App from './views/app'
import router from './router'
import store from './store'
import i18n from './locales/i18n'
import './plugins/svg'

export default render(App, {
  router,
  store,
  i18n,
  plugins,
  lazy: {
    preLoad: 1,
    loading: require('assets/img/common/loading.gif')
  },
  init: Vue => {
    // 启用全量加载(请在views/app.vue中引入样式:@import "~m2-ui/lib/theme-grace/index.css")
    // Vue.use(M2)
    // Vue.use(Element)
    // 启用按需加载(需要重新运行npm run serve)
  }
})
  • getI18nLocale 配置应用的多语言插件(集成element,m2,...)。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | langs | object | 应用多语言配置 | — | { zh: {default:true,name:'姓名'}, en: {name:'Name'} } | locales | array | 其他框架(element,m2,...)多语言配置 | — | { elementLocale, m2Locale } |

  • mergeLangs 合并其他框架的语言包与当前应用的语言包(element,m2,...)。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | appLang | object | 当前应用语言包 | — | { name: '姓名' } | langs | array | 其他框架(element,m2,...)语言包 | — | { elementLocale, m2Locale } |

  • configDefaultLang 配置默认的语言。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | lang | string | 默认语言(未配置将自动读取浏览器或系统的默认配置) | — | 'zh' |

  • changeLang 切换当前应用的语言。
  • appKey 当前多语言配置来源于第三方配置时使用。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | vm | object | 当前应用实例vm | — | — | | lang | string | 当前切换的语言 | — | 'en' | | appKey | string | 当前多语言配置的系统标识符 | — | — |

  • getRouter 获取路由配置对象。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | routerConfig | array | 路由配置对象 | — | — | | options | object | 配置选项 | — | { mode: 'hash', redirect: '/home', notmatch: '/404' } |

import { getRouter } from 'm2-vue'

const routes = [
  { path: '/home', component: () => import('views/home'), meta: { keepAlive: true, title: '首页' } },
  { path: '/category', component: () => import('views/category'), meta: { title: '分类' }  },
  { path: '/shopcart', component: () => import('views/shopcart'), meta: { title: '购物车', auth: true } },
  { path: '/profile', component: () => import('views/profile'), meta: { title: '我的', auth: true } }
]

export default getRouter(routes, { redirect: '/home', notmatch: '/404', guard: (to, from, next) => {} })
// export default getRouter(routes, { redirect: '/home', notmatch: '/404', guard: { auth: 'auth', login: 'login', before: (to, from, next) => {} }})
  • mapRoute 将路由表中的路由配置组件名(字符串)映射为真实的组件。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | route | object | 当前的路由对象 | — | { path: '/', name: 'Home', component: 'home', children: [] } | routeMap | object | 路由映射对象 | — | {'home': () => import('/views/home')}

  • mapRouteConfig 映射路由表的路由配置项。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | routes | Array | 当前的路由对象 | — | [{ path: '/', name: 'Home', component: 'home', children: [] }] | routeMap | Object | 路由映射对象 | — | {'home': () => import('/views/home')}

  • getStore 获取Vuex的Store对象。

| 参数 | 类型 | 描述 | 默认值 | 示例 | | ------------ | ------------ | ------------ | ------------ | ------------ | | options | object | 配置选项 | { state,mutations,getters,actions,modules } | — |

 import { getStore } from 'm2-vue'
 import state from './state'
 import getters from './getters'
 import mutations from './mutations'
 import actions from './actions'

 export default getStore({
   state,
   getters,
   mutations,
   actions
 })