vuejs

VueJS项目实践总结

说起来,从最初用客户端vue.js,到后面用vue-cli使用的Vue1 + webpack模版,再到后面使用Vue2+webpack,用这个框架做SPA应用也有一年半的时间了。做一些总结吧,想到哪里写哪里(针对Vue2 + webpack)。

一、页面按需加载

这主要是为了加快首屏加载速度。这样做的好处是第一屏所需加载的文件大小变小了,代价是如果用户会走完整个SPA的话,实际的总代码下载量是变多了的。按需加载页面主要就是修改/src/router/index.js文件,示例代码如下:

bridge

Exchange Singings for Tuition

I don’t know whether she really want to exchange singings for tuition, neither wouldn’t I know whether it’s for her tuition or for others’ tuition. But anyway, who cares. I think, her behavior is also a kind of business earning money at the cost of her labour. Although, it seems to be a kind of business most people are not willing to take into action, and it seems to be also a kind of business hard to earn much money.

javascript

微信PC客户端不支持object.assign方法

Recently, I encountered a bug: my frontend project can work normally in WeChat mobile clients but when visited in WeChat PC client for window OS, the page turned out be be blank -_-. After some attempts, I found that it’s due to the unavailability of Object.assign method in WeChat PC client for window OS. Therefore, we need to write polyfill for Object.assign method. There is not need to think how to write this polyfill ourselves. Just copy from MDN ^_^.

git

OSChina支持Pages功能了

This is not a new function supported by OSChina, but I’m just aware of that yesterday. Long time ago, I had once made a choice whether to use github or OSChina to be the repository storing my public code, and I finally use github later due to the fact that I found OSChina seems to have to function like github Pages. You know, as I front end developer, it’s import to show not both your code but also its visual display to others. Therefore, functions like github pages are very meaningful to me and it’s also very convenient. Without functions like github pages, I will need to build my code and then use FTP/SFTP tools like FileZilla to upload my frontend static files to my server. If you change your code in high frequency, you will find this way quite time-wasting. Whereas if you use github pages, all you need to do after rebuild your code is type one line’s command in your command line tools and press enter button ^_^.

vuejs

Vuex Data Persistence数据持久化

In one of my frontend project using VueJS, there is a need to maintain run-time data in javascript to local hardware so that these data will not be lost in case of a page refreshing. This requirement can be saying in another way – data persistence is required. Since the diversity of frontend environment, there are many stuff can be employed to save your run-time data. For example, if you use react-native, you can use one of React Native’s API called AsyncStorage; if you are written html webpage, the Html api sessionStorage, localStorage and cookie can all be employed. And today we are going to employ localStorage, we’re going to talk about data persistence in webpage developed using VueJS.

javascript

javascript验证组织结构代码

组织机构代码是对中华人民共和国内依法注册、依法登记的机关、企、事业单位、社会团体,以及其他组织机构颁发一个在全国范围内唯一的、始终不变的代码标识。国家质检总局负责组织机构代码的管理工作。

如同居民的身份证一样,组织机构代码证是组织机构在社会经济活动中统一赋予的单位身份证。组织机构代码系统覆盖范围广泛,对申领代码单位的资质审核也有数字档案(档案数字化)作为凭证,可以动态追溯每一个组织机构的历史发展变化。

shining_girl

书摘·杀死一只反舌鸟

“赫克,”阿蒂克斯转过身去说,“如果我们隐瞒这件事,那就完全否定了我教育杰姆的做人原则。有时候,我觉得自己做家长很失败,可是我就是他们拥有的一切。在杰姆仰视别人之前,他首先仰视的是我,我希望自己正直地活着,以便能坦然面对他……如果我默许这类事情发生,坦率地讲,我就没法再正视他的眼睛,一旦我不能正视他的眼睛,我就知道自己已经永远失去了他。我不像失去他和斯库特,因为他们就是我的一切。”

react_native

React Native系列之BackAndroid

检测硬件设备上的返回按钮被“按”的事件,如果未绑定监听器或者没有返回true的监听器,那么按返回键默认会关闭app。订阅该事件的监听器会以与订阅顺序相反的顺序被执行(最后订阅该事件的监听器最先被执行),并且如果有一个监听器返回了true,那么在此之前订阅该事件的监听器将不再被执行。

spring

400 bad request: Required request part ‘file’ is not present

最近碰到一个更新用户个人头像的需求,允许用户选择APP内置的几张示例图片作为头像,也允许用户拍照上传个人头像(不论是选择示例图片作为个人头像还是用户自己拍照作为个人头像,均会在文件字段之外再传其他参数,比如图片名,不只是一个文件字段)。计划中的接口是一个,拍照上传头像是由iOS和android开发在壳的层面上负责完成的,选择示例图片作为用户个人头像是在React Native层面予以实现的。因为是同一个接口,出于统一的目的,请求头中的Content-Type都使用“multipart/form-data; boundary=分隔符“这样的值(比如:Content-Type: multipart/form-data; boundary=”bac9aebd-d9ff-40ef-bcf3-4fffdd1b2c00″)。壳发的上传图片请求能正常地被服务器端处理,但是RN发的文件为空的请求就没法正常被处理,只知道报错信息为:400 bad request: Required request part ‘file’ is not present,跟后端交涉后被告知以前没有处理过不传文件的情况,还说他们写的是中间件,请求进不了断点的话他们也处理不了。。。

git

git version rollback

tengyunfengdeMacBook-Pro:test-git yakima$ git log
commit 25c92d1f05c56827b306689f426278e1cba8e837
Author: Yakima
Date: Mon Jul 31 10:24:00 2017 +0800

third commit

commit 13d46518f355aa88e85979d616203748c38dde33
Author: Yakima
Date: Mon Jul 31 10:23:35 2017 +0800

second commit

commit 0b01db0d3923ec3cfa8b643286ff9333c20cc5de
Author: Yakima
Date: Mon Jul 31 10:21:59 2017 +0800

first commit