ttk-cli / uni-vue3-vite-ts-pinia Goto Github PK
View Code? Open in Web Editor NEWA template for uniapp with vue3.
License: MIT License
A template for uniapp with vue3.
License: MIT License
打包微信小程序运行报错 [ WXSS 文件编译错误] ./app.wxss unexpected token "*",此问题可以通过在unocss.config.ts中设置theme: {preflightRoot: ['page,::before,::after']}来解决,同时由于小程序不支持 \ : [ $ . [等转义类名,bg-#81ecec例如这种,同样会在运行时报错,可使用unocss-preset-weapp解决小程序不兼容的相关问题.
这个addPage文件, 是怎么使用的, 使用node ./auto/addPage.ts运行, 报语法错误.
我通过这样使用是不成功的 const worker = uni.createWorker('workers/index')
目前 const apiEnv: ApiEnv = "dev"; 是写死的。那怎么通过package.json的执行命令来更改 /config/env.ts 中的apiEnv的值?来判断是开发还是线上环境?
能不能以此仓库再创建一个新的示例仓库写几个demo示例?看了下用到了很多插件,但是不知道如何使用,这些都是新技术,希望有个参考的示例。
控制台报错提示
node:events:505
throw er; // Unhandled 'error' event
^
Error: EBUSY: resource busy or locked, lstat 'E:\DumpStack.log.tmp'
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (file:///E:/webExe/uni-vue3-vite-ts-pinia/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/watch.js:4246:10)
at ReaddirpStream.NodeFsHandler._boundHandleError (file:///E:/webExe/uni-vue3-vite-ts-pinia/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/watch.js:2720:43)
at ReaddirpStream.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4082,
code: 'EBUSY',
syscall: 'lstat',
path: 'E:\\DumpStack.log.tmp'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
该如何解决
在作者给出的test示例中,对于 useInit
是这样使用的:
onLoad(() => { const { pageName, pagePath, pageQuery } = useInit(); console.log(pageName, pagePath, pageQuery, 'pageName,pagePath, pageQuery'); });
此时存在问题:
解构出来的变量只允许在 onLoad 作用域中使用,无法提供给 template
使用。 我尝试过将 onLoad
生命周期也放入 useInit 进行管理,但出现了很奇怪的bug,最后失败了。
有没有更好的解决方案呢?我希望解构出来的变量可以在 setup
下作为全局变量使用,而不是只能在 onLoad
中使用的局部变量
编译器版本:3.4.6(vue3)
vite v2.9.5
运行到android12 模拟器
报错信息1:
Browserslist: caniuse-lite is outdated. Please run: 10:44:03.434 npx browserslist@latest --update-db 10:44:03.442 Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
报错信息2:
[plugin:vite:load-fallback] Could not load /__uno.css (imported by src/main.ts): ENOENT: no such file or directory, open 'D:\__uno.css'
表现为只有tabs;
uniapp-cli 升级到最新的正式版 3.0.0-3061820230117001
npm i 之后报错
`npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @dcloudio/[email protected]
npm ERR! node_modules/@dcloudio/types
npm ERR! dev @dcloudio/types@"2.5.17" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @dcloudio/types@"^3.0.20" from @dcloudio/[email protected]
npm ERR! node_modules/@dcloudio/uni-app
npm ERR! @dcloudio/uni-app@"3.0.0-3061820230117001" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\PF37EXR8\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\PF37EXR8\AppData\Local\npm-cache_logs\2023-02-21T02_47_09_258Z-debug-0.log`
之后 npm i --legacy-peer-deps
报错
`
10:53:14.919 failed to load config from D:\temp-storage\uni-vue3-vite-ts-pinia\vite.config.ts
10:53:14.919 error during build:
10:53:14.927 TypeError: vite.createFilter is not a function
10:53:14.934 at vuePlugin (D:\temp-storage\uni-vue3-vite-ts-pinia\node_modules@vitejs\plugin-vue\dist\index.cjs:2601:23)
10:53:14.935 at createPluginVueInstance (D:\temp-storage\uni-vue3-vite-ts-pinia\node_modules@dcloudio\vite-plugin-uni\dist\vue\options.js:17:12)
10:53:14.949 at uniPlugin (D:\temp-storage\uni-vue3-vite-ts-pinia\node_modules@dcloudio\vite-plugin-uni\dist\index.js:80:55)
10:53:14.950 at Object. (D:\temp-storage\uni-vue3-vite-ts-pinia\vite.config.ts:94:40)
10:53:14.963 at Module._compile (node:internal/modules/cjs/loader:1165:14)
10:53:14.967 at Object.require.extensions. [as .ts] (D:\temp-storage\uni-vue3-vite-ts-pinia\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:61679:20)
10:53:14.979 at Module.load (node:internal/modules/cjs/loader:1043:32)
10:53:14.980 at Function.Module._load (node:internal/modules/cjs/loader:878:12)
10:53:14.990 at Module.require (node:internal/modules/cjs/loader:1067:19)
10:53:14.991 at require (node:internal/modules/cjs/helpers:103:18)
`
升级vite
.2.9.5 > 3.2.4
运行报错
reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack -> at useStore2 (app-service.js:1658:15) at useStore (app-service.js:1812:43) at (app-service.js:1818:29) at (app-service.js:2127:3)
救命啊老铁~
由于微信小程序的独特打包,对“\”不能作出有效识别,因此导致一些语法如:
w-30% m-30%
bg-#fff color-#fff
无法正常使用,会引起微信小程序报错
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)@commitlint/config-conventional
, commitlint
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@commitlint/config-conventional
, @dcloudio/uni-app
, @dcloudio/uni-app-plus
, @dcloudio/uni-automator
, @dcloudio/uni-cli-shared
, @dcloudio/uni-components
, @dcloudio/uni-h5
, @dcloudio/uni-mp-alipay
, @dcloudio/uni-mp-baidu
, @dcloudio/uni-mp-kuaishou
, @dcloudio/uni-mp-lark
, @dcloudio/uni-mp-qq
, @dcloudio/uni-mp-toutiao
, @dcloudio/uni-mp-weixin
, @dcloudio/uni-quickapp-webview
, @dcloudio/vite-plugin-uni
, autoprefixer
, commitizen
, pinia
, postcss-scss
, vite
, vue
)package.json
@dcloudio/uni-app 3.0.0-alpha-3040720220422004
@dcloudio/uni-app-plus 3.0.0-alpha-3040720220422004
@dcloudio/uni-components 3.0.0-alpha-3040720220422004
@dcloudio/uni-h5 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-alipay 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-baidu 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-kuaishou 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-lark 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-qq 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-toutiao 3.0.0-alpha-3040720220422004
@dcloudio/uni-mp-weixin 3.0.0-alpha-3040720220422004
@dcloudio/uni-quickapp-webview 3.0.0-alpha-3040720220422004
pinia 2.0.13
pinia-plugin-persist-uni 1.1.5
sass 1.49.9
vue 3.2.33
@commitlint/config-conventional 16.2.1
@unocss/preset-rem-to-px 0.45.1
@dcloudio/types 2.5.17
@dcloudio/uni-automator 3.0.0-alpha-3040720220422004
@dcloudio/uni-cli-shared 3.0.0-alpha-3040720220422004
@dcloudio/vite-plugin-uni 3.0.0-alpha-3040720220422004
@typescript-eslint/eslint-plugin 4.15.1
@typescript-eslint/parser 4.15.1
@vue/eslint-config-typescript 7.0.0
auto-import-types 0.0.4
autoprefixer 10.4.4
commitizen 4.2.4
commitlint 16.2.3
cz-customizable 6.3.0
eslint 7.32.0
eslint-config-prettier 8.3.0
eslint-plugin-import 2.26.0
eslint-plugin-prettier 3.3.1
eslint-plugin-simple-import-sort 7.0.0
eslint-plugin-vue 7.0.0
husky 7.0.4
pinia-auto-refs 0.0.4
postcss-html 1.3.0
postcss-scss 4.0.3
stylelint 14.1.0
stylelint-config-standard 24.0.0
stylelint-order 5.0.0
stylelint-scss 4.0.1
typescript 4.6.3
unocss 0.31.13
unplugin-auto-import 0.9.2
unplugin-vue-components 0.21.1
vite 2.9.5
vue-global-api 0.4.1
vue-tsc 0.29.3
node >=16.0.0
遇到一个奇怪的问题:
1.在src/config/env.ts中使用import.meta.env.MODE无法正常编译,其他文件可以使用。
2.在src/config/env.ts中使用uni的API无法正常编译(uni is not defined),其他文件可以使用。
微信小程序开发过程中app.wxss文件内会编译出*星号css选择器,导致运行时候报错
[自动热重载错误 WXSS 文件编译错误] ./app.wxss
unexpected token "*"
我看作者您在.vscode/settings.json中关闭了自动保存和eslint修复,想必原因是因为保存的时候,eslint语法修正和prettier语法美化之间会发生冲突格式化,其实很简单的解决思路就是直接把项目中所有有关prettier的依赖和配置都删除掉,默认使用eslint的格式化也是很不错的方案。
可以参考前端大神antfu的专题文章:
《为什么我不使用 Prettier》 - https://antfu.me/posts/why-not-prettier-zh
有没有好的前端模板推荐
有哪些ui框架兼容uniapp小程序这套的,推荐下
目前的addPage脚本需要通过开发者自行维护pages.json的内容,然后再根据这个配置来创建页面。
期望:
开发者输入npm run addPage xxx 会在url/pages新建该xxx的相关目录文件,且pages.json会直接新增该页面配置
addSubPage同理
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.