0
点赞
收藏
分享

微信扫一扫

VUE项目踩坑记录(持续更新)

NicoalsNC 2023-02-05 阅读 100

1.this.$router.push({path:'',query:{show:true}})
通过路由传的参数为Boolean时,接收的时候为String类型
2.详情页回列表定位到之前位置
detail页返回到列表页定位到之前的界面,而新增和编辑不需要,因为列表页都需要重新渲染

{
path:'/',
meta:{keepAlive:true}
}
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
router.beforeEach((to,form,next)=>{
['‘当前路由’].includes(to.name){
from.meta.keepAlive = true
}
})

3.Cannot read property 'protocol' of undefined

VUE项目踩坑记录(持续更新)_vue


具体原因出在了 main.js 中引用了 axios,同时在其它的类中使用了 axios 的请求,Vue.use(axios),删除即可

4.These dependencies were not found:core-js/modules/xxxx in ./src/xxxx/xxx

找到根目录下babel.config.js文件 ,加入配置:
module.exports = {
presets: [['@vue/app', { useBuiltIns: 'entry' }]]
}

  1. ​yarn run dev​​启动项目后,浏览器输入​​http://localhost:8060​​后,显示无法访问此网络,localhost拒绝了我们的🔗请求。

    vue.config.js中host改为​​0.0.0.0​

devServer: {
host: '0.0.0.0',
}

6.vue3 项目中报错:​​The requested module 'vite' does not provide an export named 'isCSSRequest'​

$ vite
failed to load config from /Users/zbs/vite-@vue3/vite.config.ts
error when starting dev server:
file:///Users/zbs/vite-@vue3/node_modules/@vitejs/plugin-vue/dist/index.mjs:2
import { isCSSRequest, normalizePath as normalizePath$1, transformWithEsbuild, formatPostcssSourceMap, createFilter } from 'vite';
^^^^^^^^^^^^
SyntaxError: The requested module 'vite' does not provide an export named 'isCSSRequest'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:124:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:179:5)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async loadConfigFromBundledFile (file:///Users/zbs/vite-@vue3/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62832:21)
at async loadConfigFromFile (file:///Users/zbs/vite-@vue3/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62717:28)
at async resolveConfig (file:///Users/zbs/vite-@vue3/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62341:28)
at async createServer (file:///Users/zbs/vite-@vue3/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:61641:20)
at async CAC.<anonymous> (file:///Users/zbs/vite-@vue3/node_modules/vite/dist/node/cli.js:707:24)
error Command failed with exit code 1.

  • 解决方案
    vite升级到4.x,之前我的vite是3.x报错,升级后正常运行
举报

相关推荐

vue 踩坑记录

flink 踩坑记录

踩坑记录一

RabbitMq踩坑记录

错误踩坑记录

TabLayou踩坑记录

0 条评论