vue.js源码学习分享(一)
今天看了vue.js源码 发现非常不错,想一边看一遍写博客和大家分享
/**
* Convert a value to a string that is actually rendered.
*转换一个值为字符串
*/
function _toString (val) {
return val == null? '': typeof val === 'object'? JSON.stringify(val, null, 2): String(val)
//如果该值是null则返回空字符串,如果该值为对象,则返回json字符串,否则把对象的值转化为字符串
//知识点:JSON.stringify(val, null, 2),String(val)
}
/**
* Convert a input value to a number for persistence.
* If the conversion fails, return original string.转化一个输入值为一个数字,如果转换失败,则返回原始的字符串
*/
function toNumber (val) {
var n = parseFloat(val);
return isNaN(n) ? val : n//判断n是不是 不是数字,如果不是数字则返回字符串,如果是则返回转换好的数字
}
/**
* Remove an item from an array//从数组删除一个元素
*/
function remove (arr, item) {
if (arr.length) {
var index = arr.indexOf(item);//获取元素的位置
if (index > -1) {//如果元素存在
return arr.splice(index, 1)//从数组中删除并且返回这个元素
}
}
} /**
* Check whether the object has the property.//检查对象中是否有这个属性
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;//从对象的原型中获取hasOwnProperty这个方法 function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
vue.js源码学习分享(一)的更多相关文章
- vue.js源码学习分享(九)
/* */ var arrayKeys = Object.getOwnPropertyNames(arrayMethods);//获取arrayMethods的属性名称 /** * By defaul ...
- vue.js源码学习分享(七)
var _Set; /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) { // use ...
- vue.js源码学习分享(六)
/* */ /* globals MutationObserver *///全局变化观察者 // can we use __proto__?//我们能用__proto__吗? var hasProto ...
- vue.js源码学习分享(八)
/* */ var uid$1 = 0; /** * A dep is an observable that can have multiple * directives subscribing() ...
- vue.js源码学习分享(五)
//配置项var config = { /** * Option merge strategies (used in core/util/options)//选项合并策略 */ optionMerge ...
- vue.js源码学习分享(四)
/** * Generate a static keys string from compiler modules.//从编译器生成一个静态键字符串模块. */ function genStaticK ...
- vue.js源码学习分享(三)
/** * Mix properties into target object.//把多个属性插入目标的对象 */ function extend (to, _from) { for (var key ...
- vue.js源码学习分享(二)
/** * Check if value is primitive//检查该值是否是个原始值 */ function isPrimitive (value) { return typeof value ...
- Vue.js 源码学习笔记
最近饶有兴致的又把最新版 Vue.js 的源码学习了一下,觉得真心不错,个人觉得 Vue.js 的代码非常之优雅而且精辟,作者本身可能无 (bu) 意 (xie) 提及这些.那么,就让我来吧:) 程序 ...
随机推荐
- label自适应文本大小
UILabel *label = [[UILabelalloc] initWithFrame:CGRectZero]; NSString *string = @"aa2fkoksdajfis ...
- odoo前端
bootstrap: http://www.runoob.com/bootstrap/bootstrap-tutorial.html javascript: http://www.runoob.com ...
- 浅探webpack优化
由于前端的快速发展,相关工具的发展速度也是相当迅猛,各大框架例如vue,react都有自己优秀的脚手架工具来帮助我们快速启动一个新项目,也正式因为这个原因,我们对于脚手架中最关键的一环webpack相 ...
- paper:synthesizable finite state machine design techniques using the new systemverilog 3.0 enhancements 之 standard verilog FSM conding styles(二段式)
1.Two always block style with combinational outputs(Good Style) 对应的代码如下: 2段式总结: (1)the combinational ...
- python爬虫基础13-selenium大全7/8-异常
Selenium笔记(7)异常 本文集链接:https://www.jianshu.com/nb/25338984 完整文档 Exceptions that may happen in all the ...
- AreYouBusy HDU - 3535 (dp)
AreYouBusy Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 并查集:CDOJ1593-老司机破阵 (假的并查集拆除)
老司机破阵 Time Limit: 4500/1500MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Problem Descri ...
- 牛客网 Wannafly挑战赛21 灯塔
Z市是一座港口城市,来来往往的船只依靠灯塔指引方向.在海平面上,存在n个灯塔.每个灯塔可以照亮以它的中心点为中心的90°范围.特別地, 由于特殊限制,每个灯塔照亮范围的角的两条边必须要么与坐标轴平行要 ...
- 《Scrum实战》第1课【知易行难】全团课后任务汇总
1组 孟帅(班长) kecyru 2017-7-5 http://kecyru.blog.163.com/blog/static/27416617320176411513013 htt ...
- Python ORM
本章内容 ORM介绍 sqlalchemy安装 sqlalchemy基本使用 多外键关联 多对多关系 表结构设计作业 ORM介绍 如果写程序用pymysql和程序交互,那是不是要写原生sql语句.如果 ...