Vue
RaySunWHUT
I am a coder and at the same time, I am a writer.
自认国学初窥门径,写文章胜过写程序。
个人主页: https://raysunwhut.github.io/
展开
-
Vue: SyntaxError: Unexpected token o in JSON at position 1
SyntaxError: Unexpected token o in JSON at position 1原创 2020-08-28 12:41:00 · 5333 阅读 · 0 评论 -
Vue: 使用导航守卫拦截非法请求
Vue: 使用导航守卫拦截非法请求使用导航守卫拦截非法请求,大致步骤如下:前提: 规范路由(router.js)的跳转路径: 对于 获取权限后 ,才能访问的路径,修改其前缀(此处为将需要权限才能访问的请求路径前缀设为 “/user”)。router.js 如下图:封装 Storage对象在 main.js 中使用 导航守卫在 Vue-CLI 项目的 main.js 中,添加以下代码:router.beforeEach((to, from, next) => { if (原创 2020-08-27 14:56:15 · 776 阅读 · 0 评论 -
Vue: vue-router路由传参方法
Vue: vue-router路由传参方法这里不对 vue-router 的 传参方法 展开讨论,这里只阐述 最有效、最省力 的 传参 方法.模板 (Template): this.$router.push({ path: '/path', query: { paramName: paramValue } })router.js 中的路由配置: { path: "/pa原创 2020-08-27 14:24:34 · 287 阅读 · 0 评论 -
Web Storage: sessionStorage与localStorage
Web Storage: sessionStorage与localStorage下面将从零开始,分析 Web Storage 的前世今生:前世Web Storage API 提供了存储机制,通过该机制,浏览器可以安全地存储 键值对 ,比使用 cookie 更加直观。Web Storage 的存储对象是简单的 键-值存储,类似于对象,但是它们在页面加载时保持完整。键和值始终是 字符串(请注意,与对象一样,整数键将自动转换为字符串)。您可以像访问对象一样访问这些值,或者使用 Storage.getI原创 2020-08-27 14:10:54 · 411 阅读 · 0 评论 -
Vue: 使用Vuex 保存 Javascript对象、数组
Vue: vuex保存Javascript对象Storage.js:const storage = { set(key, value) { window.sessionStorage.setItem(key, value) }, get(key) { return window.sessionStorage.getItem(key) }, remove(key) { window.sessionSto原创 2020-08-23 19:28:34 · 10867 阅读 · 1 评论 -
Vue: 将axios封装为Javascript对象
Vue: 将axios封装为Javascript对象原创 2020-07-21 09:11:04 · 603 阅读 · 0 评论 -
Vue: Electron打包Vue项目后,首界面空白(electron:serve正常,electron:build异常)
Vue: Electron打包Vue项目后,首界面空白这个问题呢,是在开发到最后,准备 push 项目到 github 时出现的问题。当我用 npm run electron:build 打包项目后,再次安装打开项目,发现首页空白。更奇怪的现象是,当我 使用 npm run electron:serve 时,界面却可以正常显示,并且一切正常!此时,回头查看了一下项目的路由 router ,可能影响到Electron打包的几个路由,都在这里:我将 path: * 如下图所示,取消注释后,n原创 2020-07-19 09:31:25 · 12619 阅读 · 1 评论 -
Vue: 页面初始化时element-ui Message自动跳出
Vue: 页面初始化时element-ui Message自动跳出Solution:// 注释掉Vue.use(Message), 使用Vue.prototype.$message = Message;, 否则每次进入页面的会自动出现 message 提示// Vue.use(Message);Vue.prototype.$message = Message;原创 2020-07-12 16:01:36 · 885 阅读 · 1 评论 -
JavaScript: 箭头函数 与函数(function)的区别
JavaScript: 箭头函数(=>) 与函数(function)的区别在Vue项目中,使用Element-UI后,浏览器控制台报错!具体错误如下:Uncaught (in promise) TypeError: Cannot read property '$message' of undefined at eval此时,前端接口代码如下:register() { var _this = this http({ // 假设后台需要的是表单数据这里你原创 2020-07-11 10:04:19 · 764 阅读 · 0 评论 -
Vue: 修改Vue项目运行端口号
修改Vue项目运行的端口号在Vue项目下的vue.config.js增加如下配置:module.exports = { devServer: { port: 8081 // 此处修改你想要的端口号 }}重启项目,即可。...原创 2019-11-25 17:40:51 · 13858 阅读 · 8 评论 -
npm使用过程中出现的一些问题
Problem:为何在命令行下操作后,package.json生成在C盘的根目录下?Solution:利用NPM创建package.json,若要创建到指定目录,需要在命令cd到目标目录,之后,进行npm init等操作。Problem:Solution:npm i npm -g即可!Problem: Node.js的安装与配置Solution:Problem: NPM淘宝镜...原创 2019-10-30 17:23:46 · 283 阅读 · 0 评论 -
vue ui命令报错
Problem“vue ui”命令报错“spawn cmd ENOENT“Solution在用户变量的PATH中添加 “%SystemRoot%\system32”,即可。原创 2019-10-30 16:50:54 · 4062 阅读 · 12 评论 -
Question:vue-cli编译运行通过,但启动app后, 界面显示空白
直接在启动页面,按F12查看浏览器的console输出的error,定位到error所在代码为止,直接修改即可。原创 2019-10-25 20:11:57 · 1968 阅读 · 0 评论 -
修改vue-cli的包管理器
如何修改vue-cli的包管理器?如:将yarn改为npm。Solution:在 C:\Users\你的用户名(如:Administrator) 找到名为“.vuerc”的文件:然后修改包管理器选项即可:...原创 2019-10-31 00:04:47 · 836 阅读 · 0 评论