Giter Site home page Giter Site logo

sunniejs / vue-h5-template Goto Github PK

View Code? Open in Web Editor NEW
3.0K 38.0 864.0 8.11 MB

:tada:vue搭建移动端开发,基于vue-cli4.0+webpack 4+vant ui + sass+ rem适配方案+axios封装,构建手机端模板脚手架

Home Page: https://sunniejs.github.io/vue-h5-template/

License: MIT License

JavaScript 16.57% HTML 2.04% Vue 23.85% Shell 0.51% TypeScript 38.73% CSS 15.53% SCSS 2.36% Dockerfile 0.40%
vue vant rem vue-cli4 sass axios vant-demo h5

vue-h5-template's Introduction

vue-h5-template

基于 vue3 + vite + (nutui or varlet or vant) + sass + viewport 适配方案 + axios 封装,构建手机端模板脚手架

如果你不熟悉 vue3,想继续使用 vue2 开发的,可以点这里来获取 vue2-h5-template

详细的说明文档请点击查看

如果对你有帮助送我一颗珍贵的小星星(づ ̄ 3  ̄)づ ╭❤ ~

关于我

扫描添加下方的微信并备注加交流群(已超过 200 人,只能邀请),交流学习,及时获取代码最新动态。

如果你觉得该项目有给你带来帮助,方便了你的日常开发,可以请作者喝一杯 ☕ 支持持续的迭代

WechatPay AliPay

Star History

Star History Chart

vue-h5-template's People

Contributors

bigsnowballhehe avatar cyyspring avatar fonghehe avatar gdoudeng avatar jiangmenghao avatar shenlanchenwei avatar vintonhuang avatar wcyspring avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-h5-template's Issues

建议把node-sass改为sass

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

建议把node-sass改为sass,解决下载问题

程序启动失败了

➜  vue-h5-template git:(vue-h5-template) yarn -v
1.22.18
➜  vue-h5-template git:(vue-h5-template) node -v
v14.19.2
➜  vue-h5-template git:(vue-h5-template) yarn install 
yarn install v1.22.18
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The engine "pnpm" appears to be invalid.
[3/4] Linking dependencies...
[4/4] Building fresh packages...

$ husky install
husky - Git hooks installed
Done in 4.10s.
➜  vue-h5-template git:(vue-h5-template) yarn dev    
yarn run v1.22.18
$ vite
                                                                                                                                                                                                                               09:42:44
  vite v2.9.14 dev server running at:

  > Local:    http://localhost:3000/                                                                                                                                                                                           09:42:44
  > Network:  http://172.26.48.66:3000/                                                                                                                                                                                        09:42:44
                                                                                                                                                                                                                               09:42:44
  ready in 703ms.


 ERROR  Failed to resolve import "@nutui/nutui/dist/packages/Button/index.scss" from "src/plugins/nutUI.ts". Does the file exist?                                                                                              09:42:46


 ERROR  9:42:46 AM [vite] Internal server error: Failed to resolve import "@nutui/nutui/dist/packages/Button/index.scss" from "src/plugins/nutUI.ts". Does the file exist?                                                     09:42:46
  Plugin: vite:import-analysis
  File: /work/vue/vue-h5-template/src/plugins/nutUI.ts
  33 |    GridItem
  34 |  } from "@nutui/nutui";
  35 |  import '@nutui/nutui/dist/packages/Button/index.scss';
     |          ^
  36 |  import '@nutui/nutui/dist/packages/Cell/index.scss';
  37 |  import '@nutui/nutui/dist/packages/CellGroup/index.scss';
      at formatError (/work/vue/vue-h5-template/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:39080:46)
      at TransformContext.error (/work/vue/vue-h5-template/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:39076:19)
      at normalizeUrl (/work/vue/vue-h5-template/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:58354:26)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async TransformContext.transform (/work/vue/vue-h5-template/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:58503:57)
      at async Object.transform (/work/vue/vue-h5-template/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:39317:30)
      at async doTransform (/work/vue/vue-h5-template/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:50037:29)

建议生成多页面配置

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

表示支持

懒得自己集成,简单看了代码,小项目直接用你这个脚手架,支持一波 👍

keep-alive不起作用

动态设置keep-alive有问题,返回时候不起作用

<keep-alive v-if="$route.meta.keepAlive">
  <router-view></router-view>
</keep-alive>
<router-view v-else></router-view>

修改为:

<keep-alive>
  <router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view  v-if="!$route.meta.keepAlive"></router-view>

请求后使用Toast回调返回上一页面会一直返回直到首页

你好,请使用下面的模板创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。

Browser version [浏览器类型和版本]
微信开发者工具

vue-h5-template version [vue-h5-template 版本]
最新版

Vue version [Vue 版本]
2.6.11

reappear link [重现链接]

One-line summary [描述问题]
在请求返回使用Toast回调返回上一页面会一直返回直到首页

iShot2020-10-25 15 47 50

Other comments [其他信息]

sass版本就错误

npm i就没人遇到sass版本就错误的人吗?居然没人提出来?

request.js的坑。。。

// respone拦截器
service.interceptors.response.use(
response => {
Toast.clear()
const res = response.data
if (res.status && res.status !== 200) { // 这里应该判断response.status
// 登录超时,重新登录
if (res.status === 401) {
store.dispatch('FedLogOut').then(() => {
location.reload()
})
}
return Promise.reject(res || 'error')
} else {
return Promise.resolve(res)
}
},
error => {
Toast.clear()
console.log('err' + error) // for debug
return Promise.reject(error)
}
)

npm i 出错

shell> npm i --registry=https://registry.npm.taobao.org
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npm.taobao.org/@babel/runtime/-/runtime-7.8.4.tgz - [not_found] document not found
npm ERR! 404
npm ERR! 404 '@babel/runtime@https://registry.npm.taobao.org/@babel/runtime/-/runtime-7.8.4.tgz' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

history模式的publicPath为 '/'更合适吧

当前配置publicPath:'./',会导致localhost/a/b这样的路径刷新无法加载的问题。而localhost/a正常显示,从其直接跳转到localhost/a/b也正常显示。但刷新就不OK啦

是否会升级vant到3.0版本?

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

.postcssrc.js调为75会导致vant的组件ui也会被更改,全部变1/2,应该需要忽略组件的css

module.exports = { plugins: { autoprefixer: { overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8'] }, 'postcss-pxtorem': { rootValue: 37.5, propList: ['*'], //selectorBlackList: ['van-'] } } }
image

module.exports = { plugins: { autoprefixer: { overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8'] }, 'postcss-pxtorem': { rootValue: 75, propList: ['*'], //selectorBlackList: ['van-'] } } }
image

按钮没垂直居中什么原因

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

使用内置模块报错

第一步

const { url } = require('url');

浏览器报错

Uncaught ReferenceError: require is not defined

网上查找原因之后修改为

import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { url } = require('url');

浏览器报错

Uncaught SyntaxError: The requested module '/@id/__vite-browser-external:module' does not provide an export named 'createRequire'

如何才能正常引用呢= =

IE还是有点问题

开本地环境运行,ie打开,报错了,build出来ie10还是有些问题,你的demo地址是正常的

请教一个问题

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

原生移动端的体验一般是前进刷新,后退不刷新。也会有在后一页修改提交了返回前一次刷新的,或者跳到后一页列表选择一项返回修改上一页的表单。
如果vue h5项目要模仿这个体验,有方案吗?
暂时是使用keepalive+include+vuex。还是思路错了?

如何在vue页面里修改title标题

首先,非常感谢你的项目。让我从vue新手能开始简单的写页面了。
有个问题想咨询一下,如何在类似about.vue里,修改最外面的title。

path: '/about',
name: 'About',
component: () => import('@/views/home/about'),
meta: { title: '关于我', keepAlive: false }
这里的title配置不起作用。

页面缓存keepAlive代码错误

Browser version [Chrome 87]

vue-h5-template version [vue-h5-template 版本]

Vue version [Vue 2.6.12]

code

     <keep-alive v-if="$route.meta.keepAlive">
        <router-view></router-view>
      </keep-alive>
      <router-view v-else></router-view>

应该写成

     <keep-alive>
        <router-view  v-if="$route.meta.keepAlive"></router-view>
      </keep-alive>
      <router-view v-else></router-view>

why not update to vue3 and ts

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

安装依赖后,运行报错

ERROR Failed to compile with 1 errors 16:10:42
error in ./src/main.js

Syntax Error: E:\vue-H5\node_modules\eslint\lib\rules\no-octal-escape.js:41
/^(?:[^\\]|\.)*?\([0-3][0-7]{1,2}|[4-7][0-7]|0(?=[89])|[1-7])/su
^

SyntaxError: Invalid regular expression flags
at Array.forEach ()

@ multi (webpack)-dev-server/client?http://192.168.1.180:9020/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

CDN配置后项目打包运行错误

按照你的CDN配置后,项目打包npm run build , 运行打包文件,报错

错误位置:
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

require is not define

npm run lint问题

您好,非常感谢对本项目的支持,您可以在此留下你的宝贵意见和想法。
也可以添加作者微信:sunnie_song ,学习交流ლ(°◕‵ƹ′◕ლ)。

执行npm run lint 操作后,会报错
rror: Cannot find module './env.undefined'
Require stack:

  • /Users/zsword/Desktop/Code/vue-app/src/config/index.js
  • /Users/zsword/Desktop/Code/vue-app/vue.config.js
  • /Users/zsword/Desktop/Code/vue-app/node_modules/@vue/cli-shared-utils/lib/module.js
  • /Users/zsword/Desktop/Code/vue-app/node_modules/@vue/cli-shared-utils/index.js
  • /Users/zsword/Desktop/Code/vue-app/node_modules/@vue/cli-service/bin/vue-cli-service.js
    Error: Cannot find module './env.undefined'
    Require stack:
  • /Users/zsword/Desktop/Code/vue-app/src/config/index.js
  • /Users/zsword/Desktop/Code/vue-app/vue.config.js
  • /Users/zsword/Desktop/Code/vue-app/node_modules/@vue/cli-shared-utils/lib/module.js
  • /Users/zsword/Desktop/Code/vue-app/node_modules/@vue/cli-shared-utils/index.js
  • /Users/zsword/Desktop/Code/vue-app/node_modules/@vue/cli-service/bin/vue-cli-service.js

感觉是不是config中的index.js文件配置需要修改某些数据

新版本做的太棒了

一直用花裤衩的后台模板,习惯了花裤衩的axios的封装,没想到这次升级也做成了跟花裤衩类似的方案,赞赞赞~!!!希望能保持简洁,不用做过度集成,支持作者~!!!!!

谢谢作者

第一次在GitHub留言,前端小白,在自己做项目时候遇到了瓶颈来这里学习,有幸看到大佬的项目,看完直接爱了,好优雅的代码!大赞!

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.