花开半夏


  • 首页

  • 标签

  • 分类

  • 归档

js类型转换

发表于 2017-12-12 | 分类于 javascript

整理下js中 ‘==’ 的类型转换,这里确实好绕。 ‘===’ 这个就不用介绍了,不会发生类型转换,直接进行比较

主要分两种情况,类型相同和类型不同进行比较:

x,y类型相同

这一块比较简单,数字比大小,字符串比大小。

需要注意的是 NaN != NaN ,另外对象比较又是个复杂的情况了

1
2
3
NaN == NaN // false
'aa' == 'b' // false
// ...

阅读全文 »

js运算整理

发表于 2017-12-12 | 分类于 javascript

整理下js中简单的四则运算,以后别又被搞晕了

加法操作

加法操作分为以下几种情况:

字符串+数字

数字转换成字符串,然后相加

字符串+ 布尔

1
2
true + '3' // "true3"
'3'+true // "3true"

字符串 + null 或undefined

1
2
'344'+null // "344null"
'344'+ undefined // "344undefined"

对象 + 字符串或数字

对象会进行toString()转换

1
2
3
4
5
var a={a:23}
a + 23 // "[object Object]23"
243' + a // "243[object Object]"
a + true // "[object Object]true"
a + null // "[object Object]null"

阅读全文 »

ubuntu初体验(长期更新)

发表于 2017-12-05 | 分类于 linux

因为window的各种兼容问题,所以想体验下linux系统开发环境,于是就有了这篇记录文。

1、VMware下载并安装
2、ubuntu系统下载(官网下载ios格式文件)
3、系统安装

参考下面地址安装 https://blog.csdn.net/colin_lisicong/article/details/70193539

4、其他软件的一些安装链接和教程
  • 安装vscode

https://blog.csdn.net/bianlihao1993/article/details/71108233

  • 搜狗输入法

https://www.cnblogs.com/darklights/p/7722861.html

阅读全文 »

vuex的modules模块

发表于 2017-12-01 | 分类于 vue

最近在网上看到有人说到vue中的模块越来越多时,怎么管理vuex,我想到了在vuex官网看到的modules,但一直没有实践去用过。这次就专门抽出一些时间去看了看这个vuex的第五个核心概念。

vuex 文件结构

1
2
3
4
5
6
7
8
├── vuex
| ├── modules
| | ├── test.js test模块
| | └── book.js book模块
| ├── index.js 主模块
| ├── getters.js 主模块getter
| ├── actions.js 主模块actions
| ├── mutations.js 主模块mutations

vuex 的主文件 index.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
import * as actions from './actions'
import * as getters from './getters'
import {mutations,state} from './mutations'
import test from './modules/test';
import book from './modules/book';
// 如果不加上namespaced:true ,vuex会把所有模块的值映射到根store,这样可能会造成命名冲突
export default new Vuex.Store({
modules: {
book:{...book,namespaced: true},
test:{...test,namespaced: true},
index:{
state,
getters,
mutations,
actions
}
}
})

阅读全文 »

nuxt框架

发表于 2017-11-03 | 分类于 vue

nuxt框架

是用于搭建一个服务端渲染的应用。更多介绍参照官方网站:

https://zh.nuxtjs.org/

https://ssr.vuejs.org/zh/

按官方方式安装完毕,在pages目录中就可以新建文件,nuxt会根据文件名自动构建路由,不需要手动去添加。

支持sass

手动安装node-sass、sass-loader 即可,不需要额外的配置。

引入公共样式文件,则还需要在 nuxt.config.js 文件中配置:

1
2
3
4
// 在assets/scss/中设置了公共样式文件main.scss
css: [
'~assets/scss/main.scss'
]

示例网站

https://github.com/nuxt/example-auth0

https://github.com/nuxt/nuxtjs.org

mongoDB 基本命令用法

发表于 2017-10-05 | 分类于 数据库

记录下mongoDB 的一些基本命令用法,方便以后查看。

成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操作。

输入 help 查看基本的操作命令

  • 显示数据库列表: show dbs

  • 切换数据库:use <db name>

  • 显示当前数据库中的集合:show collections

  • 显示用户:show users

  • 查看当前使用的数据库:db.getName()

  • 创建数据库

MongoDB没有创建数据库的命令,但有类似的命令。

如:如果你想创建一个“myTest”的数据库,先运行use myTest命令,之后就做一些操作(如:db.createCollection('user')),这样就可以创建一个名叫“myTest”的数据库。

  • 删除当前使用数据库

如:要删除“myTest” 数据库,使用use切换到当前数据库,运行 db.dropDatabase() 。

阅读全文 »

nginx代理配置

发表于 2017-10-04 | 分类于 其他

想了解下nginx是怎么做反向代理的,所以就下载了一个在本地搭建环境试试看。

本地后端服务器地址是http://localhost:3000,采用nodeJs的框架express搭建

前端打包后的静态文件放在G:\vue-express\dist

  • nginx下载地址:http://nginx.org/en/download.html

  • nginx版本: nginx/Windows-1.12.2

阅读全文 »

react学习笔记

发表于 2017-08-27 | 分类于 react

react学习笔记

redux

Redux 莞式教程 中的一个总结:

  • store 由 Redux 的 createStore(reducer) 生成

  • state 通过 store.getState() 获取,本质上一般是一个存储着整个应用状态的对象

  • action 本质上是一个包含 type 属性的普通对象,由 Action Creator (函数) 产生

  • 改变 state 必须 dispatch 一个 action

  • reducer 本质上是根据 action.type 来更新 state 并返回 nextState 的函数

  • reducer 必须返回值,否则 nextState 即为 undefined

  • 实际上,state 就是所有 reducer 返回值的汇总

阅读全文 »

js学习笔记-原型继承

发表于 2017-08-01 | 分类于 javascript

js学习笔记,原型对象、原型链、继承。js常用的几种继承方式

原型链继承

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Parent () {
this.name = '张三';
this.friends=[ '李四', '王五'];
}
Parent.prototype.getName = function () {
console.log(this.name);
}
function Child () {
}
Child.prototype = new Parent();
var child1 = new Child();
child1.friends.push('赵六');
console.log(child1.getName()) // 张三
console.log(child1.friends) // [ '李四', '王五','赵六']
var child2 = new Child();
console.log(child2.friends); // [ '李四', '王五','赵六']

缺点:

  • 1.引用类型的属性被所有实例共享

  • 2.在创建 Child 的实例时,不能向Parent传参

阅读全文 »

记录一些js使用技巧

发表于 2017-07-24 | 分类于 javascript

记录平时工作中常用的一些js小技巧。

判断对象是否为数组

function isArray(o) {
    return Object.prototype.toString.call(o) === '[object Array]';
}

将类数组对象转为数组

方法一:
Array.prototype.slice.call(arrayLike);

方法二:
Array.from(arrayLike)

方法三:
[...arrayLike]

数组去重

[...new Set([1, "1", 2, 1, 1, 3])]  // [1,'1',2,3]

取出一个数组中的最大值和最小值

var numbers = [5, 62 , 129 , -21 , 152 , 600 , 18555, -155];
var maxInNumbers = Math.max.apply(Math, numbers);
var minInNumbers = Math.min.apply(Math, numbers);
阅读全文 »
1234
aroma

aroma

38 日志
8 分类
13 标签
GitHub
© 2018 aroma
由 Hexo 强力驱动
|
主题 — NexT.Muse v5.1.3