을 underscore.string 사용 방법, 라이브러리는 의, __s 전역 변수 (http://epeli.github.io/underscore.string/#others)를 사용하여 사용할 수 있으며, 또는 내 밑줄 속성 __ str 또는 __ 문자열.는 문서가 한 번 내 응용 프로그램에 포함 underscore.string 말한다 (requireJS와) 웹 페이지에서 세계적으로
require(['underscore','underscore.string'], function(){
console.log(s('test').capitalize().value());
});
을하지만 전혀 작동하지 않습니다
이 간단한 코드는 (제대로 설정 설정 경로로)가 제대로 작동합니다. 다음은 간단한 jsfiddle 예제입니다. 나는 아마 뭔가 잘못한 것이지만, 나는 무엇을 알아낼 수 없다.
https://jsfiddle.net/mvenrtgy/10/
관련 테스트 코드는 다음과 같습니다는 글로벌 공간을 오염시키지 않도록
require.config({
paths: {
'underscore':'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min',
'underscore.string':'https://cdnjs.cloudflare.com/ajax/libs/underscore.string/3.3.4/underscore.string.min'
}
});
require(['underscore','underscore.string'], function(){
var t = 'This is a simple text I would like to SLUGIFY using unsercore.string';
// underscore is there!
console.log(typeof _)
// now check where underscore.string is...
console.log(typeof _.str);
console.log(typeof _.string);
console.log(typeof s);
console.log(typeof _s);
document.getElementsByTagName('body')[0].innerHTML = '<p>Sample text : ' + t + '</p>';
// this line will cause an error
document.getElementsByTagName('body')[0].innerHTML += '<p><em>Slugified</em> text : ' + s(t).slugify().value() + '</p>';
});
필자는 밑줄을 사용하여 혼합 할 수 있지만 실제로는 나중에 언더 스코어에 간섭을 받고 싶지는 않습니다. 밑줄/백본 템플리트 시스템 내에서 backbone.string 함수를 실제로 사용해야하기 때문에 필 요한 호출에서 제안한 것처럼 사용할 수 없습니다. 나는 미안하다고 언급하는 것을 잊었다. 따라서 밑줄 템플릿 엔진은 전역 변수/함수에서만 작동합니다. 나는 선택의 여지가 있지만 밑줄을 긋는 방법을 찾는다. 세계적으로 접근 가능하다. – Simmoniz