반응형
"string.split is not function" 오류의 원인은 무엇입니까?
왜 내가...
Uncatched TypeError: string.split이 함수가 아닙니다.
...내가 달릴 때...
var string = document.location;
var split = string.split('/');
변경...
var string = document.location;
여기까지...
var string = document.location + '';
그 이유는document.location위치 개체입니다.기본값.toString()위치를 문자열 형식으로 반환하므로 연결이 이를 트리거합니다.
또한 문자열을 얻는 데 사용할 수도 있습니다.
아마도요.
string = document.location.href;
arrayOfStrings = string.toString().split('/');
현재 URL을 원한다고 가정합니다.
이것을 실행합니다.
// you'll see that it prints Object
console.log(typeof document.location);
너는 원한다document.location.toString()또는document.location.href
document.location문자열이 아닙니다.
당신은 아마도 사용하고 싶을 것입니다.document.location.href또는document.location.pathname대신.
절에서 if, 을 사용합니다.()예:
stringtorray = "xxxx,yyyyy,zzzzz";
if (xxx && (stringtoarray.split(',') + "")) { ...
언급URL : https://stackoverflow.com/questions/10145946/what-is-causing-the-error-string-split-is-not-a-function
반응형
'programing' 카테고리의 다른 글
| 모든 파일 및 폴더 삭제, 하위 폴더 제외 (0) | 2023.07.31 |
|---|---|
| 아이폰 앱에서 UIButton/UILabel '패딩'을 달성하는 방법 (0) | 2023.07.31 |
| 트랜잭션 내부의 SELECT 문과 트랜잭션 외부의 SELECT 문이 다릅니까? (0) | 2023.07.31 |
| 너비, 내부 너비 및 외부 너비, 높이, 내부의 차이높이 및 외부높이(jQuery) (0) | 2023.07.31 |
| 항법 컨트롤러의 투명 모달 뷰 (0) | 2023.07.31 |