All Projects → dwqs → webpack-mpvue-startup

dwqs / webpack-mpvue-startup

Licence: MIT license
A template with webpack 3 + mpvue 1 setup for projects startup

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects

Projects that are alternatives of or similar to webpack-mpvue-startup

Mpvue Vuex Demo
用mpvue构建的小程序-vue模板项目,还引入了vuex,sass,flyio等
Stars: ✭ 112 (+761.54%)
Mutual labels:  mini-program, mpvue
Mpvue Douban
基于 mpvue 实现豆瓣电影微信小程序 @zce
Stars: ✭ 288 (+2115.38%)
Mutual labels:  mini-program, mpvue
startup-sozlugu
Startup dünyasında sık kullan kelimeler ve terimler
Stars: ✭ 21 (+61.54%)
Mutual labels:  startup
miniprogram-demo
FinClip 小程序演示,用于测试小程序中相关 API 与组件能力 / Mini-Program DEMO for FinClip
Stars: ✭ 49 (+276.92%)
Mutual labels:  mini-program
vue-number-keyboard
vue-number-keyboard是基于VUE实现的数字键盘插件,当前支持整数、小数数字输入、乱序键盘,demo中给出了常用的验证码、金额数字示例。数字键盘的大小包括字体尺寸支持响应式。
Stars: ✭ 51 (+292.31%)
Mutual labels:  webpack3
webpack-entry-plus
Generate dynamic webpack bundle output names from known or unknown entry files
Stars: ✭ 24 (+84.62%)
Mutual labels:  webpack3
taro-icons
基于 Taro 的小程序图标库
Stars: ✭ 53 (+307.69%)
Mutual labels:  mini-program
Android-Touch-Helper
开屏跳过-安卓系统的开屏广告自动跳过助手
Stars: ✭ 488 (+3653.85%)
Mutual labels:  startup
uParse
📰适用于 uni-app/mpvue 的富文本解析自定义组件
Stars: ✭ 45 (+246.15%)
Mutual labels:  mpvue
electron-react
A simple and compact boilerplate for electron and react (redux, router)
Stars: ✭ 66 (+407.69%)
Mutual labels:  webpack3
tech-hubs
🏠 🏢 Where are the tech hubs in Nigeria?
Stars: ✭ 142 (+992.31%)
Mutual labels:  startup
mpvue-cnode
mpvue实现的微信小程序版的cnode论坛
Stars: ✭ 84 (+546.15%)
Mutual labels:  mpvue
open-expenses
A curated list of (private) businesses publicly sharing their expenses.
Stars: ✭ 46 (+253.85%)
Mutual labels:  startup
awesome-startup-stack
Curated list of technologies for your next startup
Stars: ✭ 32 (+146.15%)
Mutual labels:  startup
finclip-flutter-demo
FinClip Flutter 运行环境,让小程序在 Flutter 应用中无缝运行 / Flutter DEMO for FinClip
Stars: ✭ 78 (+500%)
Mutual labels:  mini-program
career-resources
Some SWE/PM/Designer related career resources for students
Stars: ✭ 154 (+1084.62%)
Mutual labels:  startup
mtapp
💫 💫 Vue全家桶(配Nuxt)+ssr服务器渲染+koa2 打造美团App项目(还在更新...)📦
Stars: ✭ 30 (+130.77%)
Mutual labels:  mpvue
mpvue-one
使用mpvue构建的ONE·一个小程序,仅供学习使用
Stars: ✭ 19 (+46.15%)
Mutual labels:  mpvue
91 Python Mini Projects
No description or website provided.
Stars: ✭ 212 (+1530.77%)
Mutual labels:  mini-program
mini-program-table
基于 WePY 实现的固定头和列的 table 组件,可根据自身需求进行修改扩展。
Stars: ✭ 14 (+7.69%)
Mutual labels:  mini-program

webpack-mpvue-startup

A template with webpack 3 + mpvue 1 setup for projects startup.

Install/安装

Install it by chare or vue-cli/可以通过 chare 或者 vue-cli 来安装:

chare init dwqs/webpack-mpvue-startup your-project-name -o remote-url-of-your-project

Above command will init your project with this template, and associate it with the remote url./上述命令会初始你的项目, 并将你的项目关联到远程的 remote-url.

字段说明

如果通过 chare 或者 vue-cli 来安装, 在安装的过程中,会需要输入一些基本信息,可以查看 meta.js 来了解. 咨询的信息都有默认值, 一般选择默认就行, 模板生成之后也可以再更改.

  • state: 状态管理工具选择,目前支持 vuex / mobx

状态全局共享

由于目前 mpvue 并不支持全局注入 vuex,所以各页面之间并不能共享 store;如果你想使用 vuex,可以用一个曲线的方式进行 store 的全局共享:

  • store 打包到 vendor.js 里面去。 Vue 代码经过打包之后,会提取 commons chunk 打包到 vendor.js 中,这个 js 文件是每个页面的入口文件所依赖的。在应用初始化的时候初始化全局的 store, 更改 CommonsChunkPlugin
// ...
new webpack.optimize.CommonsChunkPlugin({
    name: 'vendor',
    minChunks: function (module, count) {
    return (
        module.resource &&
        /\.js$/.test(module.resource) &&
        module.resource.indexOf('node_modules') >= 0
    ) || /store/.test(module.resource)
    }
}),
// ...

这种方式的缺点是不能使用 Vuex 提供的 map* 函数,如 mapActionsmapGetters 等,因为这些是 this.$store 的一个语法糖,而 mpvue 没法全局注入 Vuex,因而组件实例上并没有 $store,所以只能直接访问 store 实例进行相关操作。

  • 直接在原型上定义 $store。 Vuex 会在组件的 beforeCreate 钩子中将 store 实例挂载到组件实例上去,代码见 vuexInit,因而可以在应用初始化时直接将 store 实例定义在原型上:
// ...
import Vue from 'vue';
import store from 'path/to/store';

Vue.prototype.$store = store;
//...

这样每个组件实例上都会 $store,可以使用 Vuex 的完整功能。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].