(function($){
$.fn.myLib = function (global) {
global.text2Speech = {
getSpeaker: function (lang, maxWordsPerPhrase) {
var spkr = Object.create(speaker);
spkr.lang = lang || 'en';
// TODO: do a proper checking
// this won't prevent a non number to be assigned here
if (maxWordsPerPhrase) {
spkr.maxWordsPerPhrase = maxWordsPerPhrase;
}
if (!sayIt) {
createSayIt();
}
return speaker;
}
};
}
}(jQuery));
$(function() {
var t2s = window.myLib.text2Speech;
// console.log(t2s);
var spkr = t2s.getSpeaker('en', 16);
});
我得到Uncaught TypeError:无法读取未定义的属性'text2Speech'。我做错了什么?