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

mpvue-starter

v0.0.4

Published

mpvue starer for wechat miniapp

Downloads

5

Readme

mpvue-starter

微信小程序开发规范化插件 for mpvue

1. 安装

npm install --save mpvue-starter

2. 快速使用

import Vue from 'vue'
import store from './store'
import MpvueStarter from 'mpvue-starter'

Vue.use(MpvueStarter, {
  store,
  
  appAutoUpgrade: true
})
  • arguments

参数 | 类型 | 默认值 | 说明 --- | --- | --- | --- store | Object | {} | 将在asyncData,updateData的钩子中被使用 appAutoUpgrade | Boolean| true | 是否开启微信小程序强制更新重启

3. 组件钩子

  1. asyncData

在页面组件加载时被调用,返回一个对象或者Promise结果(对象),返回的数据直接挂载到当前组件

// 返回数据
export default {
  asyncData ({store, route, vm}) {
    return {
      nickname: 'Hello'
    }
  }
}

// 返回Promise对象
export default {
  async asyncData ({store, route, vm}) {
    const {avatar, nickname} = await store.dispatch('user/info')
    return {
      nickname,
      avatar
    }
  }
}
  • 在页面组件中含有loading字段,默认为false,在asyncData执行完成之后loading改变为true,用于在数据在加载完成后渲染页面时使用。
  • arguments

参数 | 类型 | 说明 --- | --- | --- store | Object | 插件注册时传入的对象 route | Object | 页面/程序启动参数 vm | Object | 当前页面实例

  1. updateData

在页面组件显示时被调用,返回一个对象或者Promise结果(对象),返回的数据直接挂载到当前组件

// 返回数据
export default {
  updateData ({store, route, vm}) {
    return {
      nickname: 'Hello'
    }
  }
}

// 返回Promise对象
export default {
  async updateData ({store, route, vm}) {
    const {avatar, nickname} = await store.dispatch('user/info')
    return {
      nickname,
      avatar
    }
  }
}
  • arguments

参数 | 类型 | 说明 --- | --- | --- store | Object | 插件注册时传入的对象 route | Object | 页面/程序启动参数 vm | Object | 当前页面实例

  1. shareMessage [function, Object]

在页面分享功能被唤醒时调用,返回一个对象用于设置分享内容

// 返回数据
import {shareMixin} from 'mpvue-starter'

// 样例1
export default {
  mixins: [shareMixin],
  shareMessage: {
    title: '分享标题'
  }
}

// 样例2
export default {
  shareMessage () {
    const {title} = this.detail
    return {
      title
    }
  }
}
  1. title [function, Object]

用于设置页面标题,在asyncData或updateData钩子被调用后执行

// 样例1
export default {
  title: {
    title: '标题'
  }
}

// 样例2
export default {
  title () {
    const {title} = this.detail
    return {
      title
    }
  }
}

4. 混合

  1. shareMixin

用于开启页面分享功能,shareMessage才能生效

  • 默认分享当前页面,请使用shareMessage设置分享路径

  • 默认无标题,请使用shareMessage设置分享标题

  • 默认图片为页面截图,请使用shareMessage设置分享图片

组件

  1. starter-share

分享进阶操作,添加分享到朋友圈功能

// javascript

import SatrterShare from 'mpvue-starter/package/starter-share.vue'

export default {
  components: {
    StarterShare
  },
  methods: {
    async getQRimg () {
      const {qrurl} = await fetch('get qrimg api')
      return {src: qrurl}
    },
    showShareToast () {
      this.$refs.starter.show()
    }
  }
}

// template

<starter-share :create="getQRimg" ref="starter"></starter-share>