随笔分类 -  javascript

摘要:定义:用本地特定的顺序来比较两个字符串。 语法:stringObject.localeCompare(target) 参数:target——要以本地特定的顺序与 stringObject 进行比较的字符串。 返回值:说明比较结果的数字。 (1)如果 stringObject 小于 target,则 阅读全文
posted @ 2019-01-08 09:27 逸繁 阅读(3474) 评论(0) 推荐(1)
摘要:全局上下文 非严格模式和严格模式中this都是指向顶层对象(浏览器中是window)。 函数上下文 普通函数调用模式 可能会误以为window.doSth()是调用的,所以是指向window。虽然本例中window.doSth确实等于doSth。name等于window.name。上面代码中这是因为 阅读全文
posted @ 2018-12-26 13:57 逸繁 阅读(363) 评论(0) 推荐(0)
摘要:前言 用过React的同学都知道,经常会使用bind来绑定this。 import React, { Component } from 'react'; class TodoItem extends Component{ constructor(props){ super(props); this. 阅读全文
posted @ 2018-11-23 14:04 逸繁 阅读(1618) 评论(0) 推荐(2)
摘要:javascript中有三种声明变量的方式:var、let、const 1.var 作用域:全局或局部 var的作用域可以是全局或是局部,以下分四种情况说明: (1).当var关键字声明于函数内时是局部变量,此时在函数外访问会报错。 (2)当var关键字声明于函数外时是全局变量,此时不论在函数外部还 阅读全文
posted @ 2018-11-14 14:20 逸繁 阅读(211) 评论(0) 推荐(1)
摘要:Tree Menu 一级标题 二级标题 二级标题 ... 阅读全文
posted @ 2018-11-13 16:29 逸繁 阅读(636) 评论(0) 推荐(1)
摘要:给 props 属性设置多个类型 这个技巧在开发组件的时候用的较多,为了更大的容错性考虑,同时代码也更加人性化: export default { props: { width: { type: [String, Number], default: '100px' } // 或者这样 // widt 阅读全文
posted @ 2018-11-13 16:14 逸繁 阅读(525) 评论(0) 推荐(2)