vue3+taro+Nutui 开发小程序(二)

这篇具有很好参考价值的文章主要介绍了vue3+taro+Nutui 开发小程序(二)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

上一篇我们初始化了小程序项目,这一篇我们来整理一下框架

首先可以看到我的项目整理框架是这样的:

vue3+taro+Nutui 开发小程序(二),taro,小程序

 components:这里存放封装的组件

custom-tab-bar:这里存放自己封装的自定义tabbar

interface:这里放置了Ts的一些基本泛型,不用Ts的可以忽略

pages:这里放置了小程序的所有页面

service:这里二次封装了小程序的http请求

api:这里存放用到的接口

store:这里存放pinia仓库类似于vuex@5

app.Ts 这里是小程序的入口文件

app.config.Ts 这里是小程序基本根目录下的一些配置

这就是基本的框架结构,我们一步一步来完善,首先我们找打page.json

{
  "name": "taro3-vue3-pinia",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build:weapp": "taro build --type weapp",
    "build:swan": "taro build --type swan",
    "build:alipay": "taro build --type alipay",
    "build:tt": "taro build --type tt",
    "build:h5": "taro build --type h5",
    "build:rn": "taro build --type rn",
    "build:qq": "taro build --type qq",
    "build:jd": "taro build --type jd",
    "build:quickapp": "taro build --type quickapp",
    "dev:weapp": "npm run build:weapp -- --watch --env production",
    "dev:swan": "npm run build:swan -- --watch",
    "dev:alipay": "npm run build:alipay -- --watch",
    "dev:tt": "npm run build:tt -- --watch",
    "dev:h5": "npm run build:h5 -- --watch",
    "dev:rn": "npm run build:rn -- --watch",
    "dev:qq": "npm run build:qq -- --watch",
    "dev:jd": "npm run build:jd -- --watch",
    "dev:quickapp": "npm run build:quickapp -- --watch",
    "typecheck": "vue-tsc --noEmit --skipLibCheck",
    "lint": "eslint . --fix",
    "format": "prettier . --write !**/*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro} !*.min.* !CHANGELOG.md !dist !LICENSE* !output !coverage !public !temp !package-lock.json !pnpm-lock.yaml !yarn.lock !__snapshots__",
    "commit": "git pull && pnpm format && pnpm lint && git add -A && pnpm cz && git push",
    "pre-commit": "git pull && pnpm lint-staged && pnpm cz && git push",
    "cz": "czg",
    "prepare": "husky install"
  },
  "dependencies": {
    "@babel/runtime": "^7.22.6",
    "@nutui/nutui-taro": "^4.0.12",
    "@tarojs/cli": "3.6.8",
    "@tarojs/components": "3.6.8",
    "@tarojs/helper": "3.6.8",
    "@tarojs/plugin-html": "3.6.8",
    "@tarojs/plugin-platform-alipay": "3.6.8",
    "@tarojs/plugin-platform-h5": "3.6.8",
    "@tarojs/plugin-platform-jd": "3.6.8",
    "@tarojs/plugin-platform-qq": "3.6.8",
    "@tarojs/plugin-platform-swan": "3.6.8",
    "@tarojs/plugin-platform-tt": "3.6.8",
    "@tarojs/plugin-platform-weapp": "3.6.8",
    "@tarojs/runtime": "3.6.8",
    "@tarojs/shared": "3.6.8",
    "@tarojs/taro": "3.6.8",
    "@tarojs/webpack5-runner": "3.6.8",
    "@vueuse/core": "^10.2.1",
    "lodash-es": "^4.17.21",
    "pinia": "^2.1.4",
    "qs": "^6.11.2",
    "vue": "^3.3.4"
  },
  "devDependencies": {
    "@babel/core": "^7.22.9",
    "@babel/preset-env": "^7.22.9",
    "@iconify/json": "^2.2.88",
    "@iconify/utils": "^2.1.7",
    "@tarojs/plugin-framework-vue3": "3.6.8",
    "@types/lodash-es": "^4.17.7",
    "@types/node": "^20.4.1",
    "@types/qs": "^6.9.7",
    "@types/webpack-env": "^1.18.1",
    "@unocss/webpack": "^0.53.5",
    "@vue/babel-plugin-jsx": "^1.1.5",
    "babel-loader": "^9.1.3",
    "babel-preset-taro": "3.6.8",
    "commitlint": "^17.6.6",
    "czg": "^1.7.0",
    "eslint": "^8.44.0",
    "eslint-config-soybeanjs": "^0.5.1",
    "husky": "^8.0.3",
    "lint-staged": "^13.2.3",
    "taro-plugin-pinia": "^1.0.0",
    "typescript": "5.1.6",
    "unocss": "^0.53.5",
    "unocss-preset-weapp": "^0.53.5",
    "unplugin-vue-components": "^0.25.1",
    "vue-loader": "^17.2.2",
    "vue-tsc": "^1.8.4",
    "webpack": "^5.88.2"
  },
  "lint-staged": {
    "*.{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "eslint . --fix",
    "*.!{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "format"
  }
}

然后打开终端输入 npm i 如果报错有可能是你的node版本过高,可以输入 npm i --legacy-peer-deps

打开babel.config.js

module.exports = {
  presets: [
    [
      'taro',
      {
        framework: 'vue3',
        ts: true
      }
    ]
  ],
  plugins: []
};

打开.eslintrc.js配置代码规范文章来源地址https://www.toymoban.com/news/detail-601220.html

module.exports = {
  extends: ['soybeanjs/vue'],
  overrides: [
    {
      files: ['*.vue'],
      rules: {
        'no-undef': 'off' // use tsc to check the ts code of the vue
      }
    }
  ],
  settings: {
    'import/core-modules': ['uno.css', '~icons/*', 'virtual:svg-icons-register']
  },
  rules: {
    'no-return-await': 'off',
    'import/order': [
      'error',
      {
        'newlines-between': 'never',
        groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
        pathGroups: [
          {
            pattern: 'vue',
            group: 'external',
            position: 'before'
          },
          {
            pattern: '@tarojs/taro',
            group: 'external',
            position: 'before'
          },
          {
            pattern: 'pinia',
            group: 'external',
            position: 'before'
          },
          {
            pattern: '@nutui/nutui-taro',
            group: 'external',
            position: 'before'
          },
          {
            pattern: '@/constants',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/config',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/settings',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/enum',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/plugins',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/pages',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/views',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/components',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/package',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/service',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/store',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/context',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/composables',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/hooks',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/utils',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/assets',
            group: 'internal',
            position: 'before'
          },
          {
            pattern: '@/**',
            group: 'internal',
            position: 'before'
          }
        ],
        pathGroupsExcludedImportTypes: ['vue', 'vue-router', 'pinia', '@nutui/nutui-taro']
      }
    ]
  }
};

到了这里,关于vue3+taro+Nutui 开发小程序(二)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • taro+vue3开发小程序

    一.创建项目 (1) npm install -g @tarojs/cli (2) npx @tarojs/cli init myApp  二.按需引入 nutui 组件 1.使用 babel-plugin-import插件   (1)下载插件 npm install babel-plugin-import   (2) babel.config.js配置 (3)app.js中引入

    2024年02月08日
    浏览(42)
  • Taro+Vue3 小程序引入echarts表

    背景:根据需求在一个报告界面需要展示不同的echarts表来使数据更友好的显示。 效果如下: 一.taro支持echarts 官方说明:Taro 文档支持引用小程序端第三方组件库 物料文档:Taro 物料市场 | 让每一个轮子产生价值 二.引入echarts-for-weixin插件 github地址: https://github.com/ecomfe/echar

    2024年02月13日
    浏览(24)
  • Taro+Vue3开发微信小程序的分享好友功能

    1、背景:使用taro框架和vue3框架开发小程序,实现一个把pdf文件直接分享给微信好友。 一开始看taro文档理解有偏差,导致分享出去的文件是个app的小程序连接。如下图  实现代码如下: 后续仔细查看taro文档, Taro 文档,发现这种写法是个页面组件,转发出去的是个小程序,

    2024年02月12日
    浏览(48)
  • taro+vue3 搭建一套框架,适用于微信小程序和H5

    安装 Taro。可以在终端输入以下命令进行安装: 创建项目。使用以下命令创建 Taro+Vue3 项目: 其中,myApp 是项目名称。 进入项目并启动。使用以下命令进入项目并启动: 注意,需要先进入对应的目录再启动。 编写代码。在 src 目录下编写代码,可以像使用 Vue 开发 Web 应用程

    2024年02月10日
    浏览(44)
  • taro.js和nutui实现商品选择页面

    1. 首先安装 Taro.js 和 NutUI: ``` npm install -g @tarojs/cli npm install taro-ui ``` 2. 创建 Taro 项目并进入项目目录: ``` taro init myapp cd myapp ``` 3. 选用 Taro 模板一并安装依赖: ``` npm install ``` 4. 在页面目录中创建商品选择页: ``` taro create --name goods --type page ``` 5. 在 `goods.jsx`中导入并使用

    2024年02月11日
    浏览(36)
  • Taro + vue3 实现自定义返回栏

    算是一个简单的返回页面  主要是这里 Taro +vue3 的页面结构还有一个 

    2024年04月29日
    浏览(33)
  • Taro+vue3 实现滑动列表 时切换电影

    以上代码是滑动的组件 

    2024年01月16日
    浏览(28)
  • Taro+vue3 实现选座位 功能 以及座位显示

    1.类似选座位那种功能 我的功能座位 不是html元素 而是 座位图片 都是图片 2.如果大家有需求 需要源代码 可以先私信我 源代码整理中 未来会发布开源

    2024年01月16日
    浏览(39)
  • taro vue3 ts nut-ui 项目

    查看 Taro 全部版本信息​ 可以使用  npm info  查看 Taro 版本信息,在这里你可以看到当前最新版本 使用命令创建模板项目: taro init 项目名 微信小程序自定义 TabBar 先安装 cnpm install pinia 以便解决 小程序的 页面首次加载 在 app.config.js 中设置 在  src 目录 下 pages 文件夹,在里

    2024年02月06日
    浏览(31)
  • Vue3 Vite electron 开发桌面程序

    Electron是一个跨平台的桌面应用程序开发框架,它允许开发人员使用Web技术(如HTML、CSS和JavaScript)构建桌面应用程序,这些应用程序可以在Windows、macOS和Linux等操作系统上运行。 Electron的核心是 Chromium 浏览器内核和 Node.js 运行时环境。 Chromium 内核提供了现代浏览器的功能,

    2024年02月16日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包