Giter Club home page Giter Club logo

mpvue-mall's Introduction

安装依赖

npm install

小程序运行

npm run dev

H5运行

npm run devH5

小程序打包(打包到dist目录)

npm run build

H5打包(打包到distH5目录)

npm run buildH5

开始

这个项目引用参考

github源码 => https://github.com/Aimee1608/mpvuedemo

简易说明

路由跳转

去往Vuex示例页面 去往logs页面
<script> // 组件引用 import card from '@/components/card' export default { data () { return { motto: 'Hello World' } }, components: { card }, methods: { gotoGame (path) { this.reLaunchPageTo(this.router + path) } } } </script>

分别封装方法

H5 mainH5.js方法

Vue.mixin({ data () { return { service: '', // 服务 router: '/', // 路由路径 imgSrc: '' // 图片路径 } }, methods: { newroot () { return this.$route }, navigatePageTo (url) { this.$router.push(url) }, reLaunchPageTo (url) { this.$router.replace(url) }, setStorageSync (name, data) { sessionStorage.setItem(name, JSON.stringify(data)) }, getStorageSync (name) { return JSON.parse(sessionStorage.getItem(name)) } }, created () { console.log('chrome') this.service = httpService } })

小程序main.js

Vue.mixin({ data() { return { service: '', router: '/', imgSrc: '/' } }, methods: { newroot () { return this.$root.$mp }, navigatePageTo (url) { wx.navigateTo({url: url}) }, reLaunchPageTo (url) { wx.reLaunch({url: url}) }, setStorageSync (name, data) { wx.setStorageSync(name, data) }, getStorageSync (name) { return wx.getStorageSync(name) } }, created() { this.service = wxService } })


### vuex 数据存储
>小程序store 直接挂在 Vue原型上
Vue.prototype.$store = store

>H5vue 还是和之前一样
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
  store
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.