前端,开发环境准备,vscode设置,nvm配置,uniapp环境配置,项目配置等
vscode 设置默认cmd终端
1.首先打开vscode,Ctrl+shift+p打开命令面板。
2.输如Terminal:Select Default
3.点进去选择第一个
4.重启
fittenCode安装(ai编程助手谁用谁知道)
https://code.fittentech.com/#download
通义灵码也安排上
配置快捷键为webstrom
nvm 安装
1.https://nvm.uihtm.com/
2.下载nvm(如果已经安装了node,需要卸载原来的node)
3.如果安装nvm的文件夹里没有nodejs这个文件夹的话,可以自己手动新建一个空的nodejs文件夹即可。同时环境变量需要修改
- 配置nvm下载地址,nvm根目录打开 settings.txt 文件 ,添加以下代码
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/
3.cmd输如 nvm list available(列出可以下载的node)
4.nvm install 22.3.0 接下来下载node22.3.0(适配vue3,vite等最新版本)
5.执行nvm切换版本操作 nvm use 22.3.0
6.安装 node14版本 (视频vue2,angular8等低版本) nvm install 14.21.3
OK 现在可以兼容新老项目了
7.然后安装 pnpm npm install pnpm
git+git gui
1.下载https://git-scm.com/download/win
2.安装一路下一步
3.git gui+中文包
链接: https://pan.baidu.com/s/1nVbFg8ZwjnbwcvvveZny3g?pwd=lf12 提取码: lf12
先安装gui,在安装语言包完事
点右键设置,设置自己的用户名
完成后试验下拉取,推送,OK,git搞定。
svn
TortoiseSVN下载百度搜索,先下载svn,在下载语言包。
微信开发者工具
https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html
hbuilderx(用于打包和发布)
https://www.dcloud.io/hbuilderx.html
vue-devtools
安装方法:https://blog.csdn.net/weixin_44042442/article/details/136285090
vue-tools插件安装
https://chrome.zzzmh.cn/info/nhdogjmejiglipccpnnnanhbledajbpd
下载 后打开chrome插件列表,将解压后的crx文件拖进去。
如果这样安装不行,将文件重命名为rar,然后解压。打开扩展程序,选择加载扩展程序,选择解压的文件夹。
tailwindcss
1.安装
pnpm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
2.配置模板文件的路径
tailwind.config.js
module.exports = {
content: [“./src/**/*.{html,js}”],
theme: {
extend: {},
},
plugins: [],
}
3.在 App.vue 中添加
<style>
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
</style>
4.改写vite.config.js
import { defineConfig } from 'vite';
import tailwindcss from 'tailwindcss';
import uni from '@dcloudio/vite-plugin-uni';
// https://vitejs.dev/config/
export default defineConfig({
css: {
postcss: {
plugins: [
tailwindcss(),
],
},
},
plugins: [
uni(),
],
});
5.以下为小程序适配
小程序适配 pnpm i @uni-helper/vite-plugin-uni-tailwind@0.13.1 必须安装这个版本,高的版本不兼容要报错
// vite.config.js
import { defineConfig } from "vite";
import tailwindcss from 'tailwindcss';
import uni from "@dcloudio/vite-plugin-uni";
import uniTailwind from '@uni-helper/vite-plugin-uni-tailwind';
export default defineConfig({
css: {
postcss: {
plugins: [
tailwindcss(),
],
},
},
plugins: [uni(), uniTailwind()],
});
6.rem to rpx,由于tailwind默认是rem单位,需要转到rpx
pnpm i tailwindcss-rem2px-preset -D
//tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
presets: [
require('tailwindcss-rem2px-preset').createPreset({
// 32 意味着 1rem = 32rpx
fontSize: 32,
// 转化的单位,可以变成 px / rpx
unit: 'rpx'
})
],
}
uniapp+vu3+ts配置
- 装vue脚手架npm install -g @vue/cli
- .运行uni官网命令
npx degit dcloudio/uni-preset-vue#vite-ts uniapp-test
哦豁,连不上。
问题不大,直接复制上面的网址点进去下载源代码
还是不行咱们换个地址https://gitcode.com/dcloudio/uni-preset-vue/overview?utm_source=csdn_blog_hover
解压放到你要创建的文件夹内。
uniapp vscode配置
首先安装下面这3个插件
将.create-uniapp-view设置改为vue3
然后安装ts语言包
pnpm i -D miniprogram-api-typings @uni-helper/uni-app-types
配置ts
{
"extends": "@vue/tsconfig/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"sourceMap": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"lib": ["esnext", "dom"],
"types": [
"@dcloudio/types",
"miniprogram-api-typings",
"@uni-helper/uni-app-types",
"@uni-helper/uni-ui-types"
]
},
// 校验 uni-app 组件类型
"vueCompilerOptions": {
// experimentalRuntimeMode 已废弃,现调整为 nativeTags,请升级 Volar 插件至最新版本
"nativeTags": ["block", "component", "template", "slot"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
然后
== vue-official插件,版本需要降级到2.0.12。否则组件界面会有红线。==
然后运行小程序。
package.json
{
"name": "uni-app-模板",
"version": "0.0.0",
"scripts": {
"dev:app": "uni -p app",
"dev:app-android": "uni -p app-android",
"dev:app-ios": "uni -p app-ios",
"dev:custom": "uni -p",
"dev:h5": "uni",
"dev:h5:ssr": "uni --ssr",
"dev:mp-alipay": "uni -p mp-alipay",
"dev:mp-baidu": "uni -p mp-baidu",
"dev:mp-kuaishou": "uni -p mp-kuaishou",
"dev:mp-lark": "uni -p mp-lark",
"dev:mp-qq": "uni -p mp-qq",
"dev:mp-toutiao": "uni -p mp-toutiao",
"dev:mp-weixin": "uni -p mp-weixin",
"dev:quickapp-webview": "uni -p quickapp-webview",
"dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
"dev:quickapp-webview-union": "uni -p quickapp-webview-union",
"build:app": "uni build -p app",
"build:app-android": "uni build -p app-android",
"build:app-ios": "uni build -p app-ios",
"build:custom": "uni build -p",
"build:h5": "uni build",
"build:h5:ssr": "uni build --ssr",
"build:mp-alipay": "uni build -p mp-alipay",
"build:mp-baidu": "uni build -p mp-baidu",
"build:mp-kuaishou": "uni build -p mp-kuaishou",
"build:mp-lark": "uni build -p mp-lark",
"build:mp-qq": "uni build -p mp-qq",
"build:mp-toutiao": "uni build -p mp-toutiao",
"build:mp-weixin": "uni build -p mp-weixin",
"build:quickapp-webview": "uni build -p quickapp-webview",
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
"tsc": "vue-tsc --noEmit --skipLibCheck",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"lint-staged": "lint-staged"
},
"lint-staged": {
"*.{js,ts,vue}": [
"eslint --fix"
]
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-app-harmony": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-app-plus": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-components": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-h5": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-jd": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-mp-xhs": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-ui": "^1.5.5",
"@uni-helper/vite-plugin-uni-tailwind": "0.13.1",
"pinia": "2.0.27",
"pinia-plugin-persistedstate": "^3.2.0",
"vue": "^3.4.29",
"vue-i18n": "^9.13.1"
},
"devDependencies": {
"@dcloudio/types": "^3.4.8",
"@dcloudio/uni-automator": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-4010520240507001",
"@dcloudio/uni-vue-devtools": "3.0.0-alpha-3080220230511001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4010520240507001",
"@rushstack/eslint-patch": "^1.1.4",
"@types/node": "^18.11.9",
"@uni-helper/uni-app-types": "^0.5.12",
"@uni-helper/uni-ui-types": "^0.5.11",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.0",
"@vue/runtime-core": "^3.4.29",
"@vue/tsconfig": "^0.4.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.22.0",
"eslint-plugin-vue": "^9.3.0",
"lint-staged": "^13.0.3",
"miniprogram-api-typings": "^3.12.0",
"postcss": "^8.4.38",
"prettier": "^2.7.1",
"sass": "^1.56.1",
"tailwindcss": "^3.4.4",
"tailwindcss-rem2px-preset": "^1.0.3",
"typescript": "^5.1.6",
"vite": "^5.2.8",
"vue-tsc": "^1.8.8"
}
}
更多推荐
所有评论(0)