vue3移动端脚手架(纯净,集成丰富)

概述

一个纯净的移动端框架 ,用到了 Vue3 + vuex + Vite3 + Vant3 + sass + eslint + stylelint + htmlhint + husky + commitlint axios + axios-adapter + VConsole + 自定义全局 loading ,自定义函数式 dialog (api模仿微信小程序),非常适合做脚手架。

详细

框架demo介绍

Vue3 + vuex + Vite3 + Vant3

sass

eslint + stylelint + htmlhint

husky + commitlint

axios + axios-adapter

VConsole(with custom plugin)

Custom components: loading

Custom components: dialog (api模仿微信小程序)

是一个纯净的前端框架,集成丰富,适合做二次开发。

代码目录结构

示例代码

定义api(同时可以定义mock数据,可自己写mock逻辑)

复制代码
    static login(params?: any) {
        return this.post({
          url: `/login`,
          params: params,
          statusCode: 200,
          getJsonPath() {
            const loginSuccess = import('./mock/login/login.json')
            const loginFail = import('./mock/login/loginFail.json')
            // 可以自己写逻辑判断返回不同的mock
            return loginSuccess
          }
        })
      }
    // 实现的核心代码(方便定义api的时候顺便定义mock数据)
    ![](/contentImages/image/20220805/GZzd31UCRK8Euvz0WLe.png)
    // 利用动态导入,避免非mock状态下,加载太多mock数据

使用函数式对话框

复制代码
    // api 参考微信小程序 https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
    showModal({
        content: '测试内容',
        // showCancel: false
      })

效果截图

复制代码
    // 实现思路
    import { createVNode, render } from "vue"
    import modal from './modal.vue'
    // 创建一个容器,用来放dialog
    const div = document.createElement('div')
    div.setAttribute('class', 'global_modal_container')
    document.body.appendChild(div)
    // 定义好输入
    export type ModalConfig = {
      title?: string,
      content: string,
      showCancel?: boolean,
      cancelText?: string,
      confirmText?: string,
      confirm?: Function,
      cancel?: Function,
      div?: HTMLDivElement,
    }
    export default (modalConfig: ModalConfig) => {
      return new Promise((resolve, reject) => {
        const confirm = () => {
            // 根据点击时间,把内容设置为null,达到取消弹窗的效果。
          render(null, div)
          resolve(true)
        }
        const cancel = () => {
          render(null, div)
        }
        // 判断如果没有回调,那么会返回Promise对象
        if (!modalConfig.confirm) {
          modalConfig.confirm = confirm
        }
        if (!modalConfig.cancel) {
          modalConfig.cancel = cancel
        }
        modalConfig.div = div
        const vnode = createVNode(modal, modalConfig)
        render(vnode, div)
      })
    }
相关推荐
超超~~3 天前
Notepad(文本编辑器)v3.6.30绿色官方版
编辑器·notepad++
一室易安3 天前
uniapp+vue3 微信小程序中 页面切换tab 页面滚动到指定锚点位置,滚动页面时候到达指定锚点位置吸顶tab 会自动进行切换
微信小程序·uni-app·notepad++
admin and root4 天前
渗透测试 | 分享某次项目上的渗透测试漏洞复盘
渗透测试·notepad++·漏洞挖掘·红蓝对抗·攻防演练·护网·爆破密码
何包蛋H6 天前
医疗视频播放组件开发实战:支持病灶标注、缓存播放与性能优化
微信小程序·音视频·notepad++
桐溪漂流6 天前
微信小程序的几个实用小知识
微信小程序·小程序·notepad++
han_hanker11 天前
svg 可改颜色,但似乎不支持微信小程序
微信小程序·小程序·notepad++
默魔22 天前
uniapp canvas 生成海报并保存到相册
uni-app·notepad++
JIngJaneIL25 天前
停车场管理|停车预约管理|基于Springboot+的停车场管理系统设计与实现(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·notepad++·停车场管理|
一人一程温一壶酒1 个月前
微信小程序uniapp开发附源码——图片加水印
微信小程序·uni-app·notepad++
LXA08091 个月前
UniApp 小程序中使用地图组件
小程序·uni-app·notepad++