首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >.substring error: “is not a function”

.substring error: “is not a function”

作者头像
黄啊码
发布于 2020-05-31 22:35:45
发布于 2020-05-31 22:35:45
1.1K0
举报
代码语言:javascript
复制
var currentLocation = document.location,
muzLoc = currentLocation.substring(0,45),

这时候如果执行,总是无法输出muzLoc,因为本来这个语法就出错了,document.location是一个对象,把一个对象当作字符串肯定是出错的

应该先currentLocation.toString()然后再用截取字符串

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016/03/30 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档